text
stringlengths 36
35k
| label
class label 2
classes | source
stringclasses 3
values | tokens_length
int64 128
4.1k
| text_length
int64 36
35k
|
---|---|---|---|---|
Checking HDD SMART Data from Live USB. <p>I'm trying to use a Ubuntu 18.04.2 Live USB to check SMART Data on hard drives but it asks me for the Live Session User password. I do not have persistence enabled and would prefer not to create a new account although this may not be possible. </p>
<p>Does anyone know how I can authenticate to check the SMART Data or is there not a way to do this without persistence enabled on the USB and making a new admin account? I just want to boot from this Live USB and do a short check of the SMART Data quickly</p>
<p>I appreciate any help I can get with this and thank you in advance.</p>
| 0non-cybersec
| Stackexchange | 164 | 632 |
a file to be in git or not to be?. <p>I didn't prevent same problem:</p>
<p>I don't use <code>git rm projects.py</code> and when i use :</p>
<p><code>git cp projects</code><kbd>TAB</kbd><kbd>TAB</kbd></p>
<p><code>projectsFindFrame.py projectsInsert.py</code></p>
<p>Also when i use:</p>
<pre><code>git show a3ea2118bf1c5e2c6aa0974d0b6ff7415bd044ef
</code></pre>
<p>I prevent to content of projects.py file:</p>
<pre><code>commit a3ea2118bf1c5e2c6aa0974d0b6ff7415bd044ef
Author: Mohsen Pahlevanzadeh <mohsen@debian>
Date: Wed Oct 9 04:21:14 2013 +0330
formValidators has been added, all of *_Insert component has been added to Projects() class.
diff --git a/projects.py b/projects.py
new file mode 100644
index 0000000..d76685b
--- /dev/null
+++ b/projects.py
@@ -0,0 +1,303 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+#
+
+from tables import *
+from dbabslayer import *
+from languagecodes import *
+from PyQt4 import QtCore, QtGui
+
+
+try:
+ _fromUtf8 = QtCore.QString.fromUtf8
+except AttributeError:
+ def _fromUtf8(s):
+ return s
+
+try:
+ _encoding = QtGui.QApplication.UnicodeUTF8
+ def _translate(context, text, disambig):
+ return QtGui.QApplication.translate(context, text, disambig, _encoding)
+except AttributeError:
+ def _translate(context, text, disambig):
+ return QtGui.QApplication.translate(context, text, disambig)
+
+
+
+
+class Projects(QtGui.QMainWindow):
</code></pre>
<p><strong>My Question</strong> is : Why i can't do <code>git cp projects.py</code> ? But it's to be.</p>
| 0non-cybersec
| Stackexchange | 599 | 1,567 |
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 | 349 | 1,234 |
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 | 349 | 1,234 |
RedirectToAction after ajax form submit in Asp.net Core. <p>I have a view named Index and a PartialView named '_Addbook' that shown as a bootstrap modal. In the partialView insert data into database using ajax form.</p>
<p><strong>Index view :</strong></p>
<pre><code><div class="panel panel-primary">
<div class="panel-body">
<div class="btn-group">
<a class="btn btn-primary marginbutoon" id="showBookgroup" data-toggle="modal" asp-action="AddBook"
data-target="#modal-book">
<i class="glyphicon glyphicon-plus"></i>
Add Book
</a>
</div>
</div>
</code></pre>
<p></p>
<p><strong>Partialview :</strong></p>
<pre><code> @model WebApplication1.Models.Book
<form asp-controller="Home" asp-action="AddBook" id="myform"
data-ajax="true" data-ajax-method="POST"
data-ajax-mode="replace" data-ajax-update="#myform">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
<h4 class="modal-title" id="myModalLabel">Add Book</h4>
</div>
<div class="modal-body form-horizontal">
<div class="row">
<div class="form-group">
<label asp-for="BookName" class="col-sm-3 control-label"></label>
<div class="col-lg-6">
<input asp-for="BookName" class="form-control" />
<span asp-validation-for="BookName" class="text-danger"></span>
</div>
</div>
</div>
</div>
<div class="modal-footer">
<input type="submit" class="btn btn-primary" value="Submit" />
</div>
</code></pre>
<p></p>
<p><strong>Controller :</strong></p>
<pre><code> [HttpGet]
public IActionResult AddBook()
{
var book = new Book();
return PartialView("_AddBooks", book);
}
[HttpPost]
[ValidateAntiForgeryToken]
public IActionResult AddBook(Book model)
{
if (ModelState.IsValid)
{
using (var db = _Context.GetRequiredService<ApplicationDbContext>())
{
db.bookgroups.Add(model);
db.SaveChanges();
}
return RedirectToAction("Index");
}
else
{
return PartialView("_Addbooks", model);
}
}
</code></pre>
<p>The data is stored correctly in the database and modal hide after submit but index view shows Mixed up.
How can i Redirect after ajax submit?</p>
| 0non-cybersec
| Stackexchange | 924 | 2,849 |
ASP.NET/IIS7.5 Writing Log File Not Working (Permissions, UAC, Config., ???). <p>We're having trouble migrating our ASP.NET applications to Windows Server 2008 R2 x64 and IIS7.5. The problem is that our ASP.NET apps write log files, and these log files are not being written. The only way the apps write their log files is if I'm logged into the server as the local Administrator user or if I right click and run IE as Run as Administrator, neither of which is an acceptable solution for us.</p>
<p>Our platform is:
Windows Server 2008 R2 x64 (UAC setting is the default setting)
IIS7.5
ASP.NET 4.0 (using Windows authentication and impersonation, both on in web.config)</p>
<p>Our app gets installed to:
D:[appname]
[appnameWebSite] (all the .aspx, .dll, etc. files are in here)
\Log (the app tries to write the log file to this folder)</p>
<p>On the server:
Created new App Pool (name: [appname], .NET 4.0, Managed Pipeline Mode: Classic, Identity: ApplicationPoolIdentity, Load User Profile: False, all other properties are the defaults)
Created IIS application pointing to D:[appname][appnameWebSite] and added it the the new App Pool (Full trust level)
Have a domain user in local Administrators group</p>
<p>With all the configuration and default settings listed above, the ASP.NET app will not write the log file. The app appears to work fine in the browser, but no log.txt file.</p>
<p>To try to "fix" this issues, we've tried many things:
Tried Application Pool setting: Managed Pipeline Mode: Integrated
Tried Application Pool setting: Identity: NetworkService
Tried Application Pool setting: Identity: LocalSystem
Tried Application Pool setting: Load User Profile: True
Gave Users group full control to file system for our application folder structure (tried appname folder, tried Log folder only, tried appnameWebSite and Log folders only)
Gave IIS AppPool[appname] (matching the new App Pool) user full control to file system for our application folder structure (tried appname folder, tried Log folder only, tried appnameWebSite and Log folders only)</p>
<p>None of these things helped. Again, the app would run fine, just no log file created.</p>
<p>As mentioned above, the only way that the log file is created when the app runs is if we log into the server using the local Administrator account (which makes sense since he's a super user) or if we run IE as administrator and elevate privileges.</p>
<p>Any suggestions? Help? Questions?</p>
<p>Thanks!</p>
| 0non-cybersec
| Stackexchange | 657 | 2,496 |
Javascript : How to create global functions & variables. <p>I would like to create a new function that I can use on elements, like this:</p>
<pre><code>document.getElementById("element").myNewFunction();
</code></pre>
<p>I'm not talking about this:</p>
<pre><code>document.getElementById("element").myNewFunction = function(){
doSomething...
}
</code></pre>
<p>Because this works on that element only, but how should I create global function what I can use on all elements like the ones what are built in to JavaScript?</p>
| 0non-cybersec
| Stackexchange | 148 | 535 |
Linux ethernet bridge can be accessed behind a router. <p>I run Debian 8 and need to bridge a tap interface <code>tap0</code> to <code>eth0</code> (trying to setup an OpenVPN server). I use the standard bridging script from OpenVPN help page:</p>
<pre><code>#!/bin/sh
# Define Bridge Interface
br="br0"
# Define list of TAP interfaces to be bridged,
# for example tap="tap0 tap1 tap2".
tap="tap0"
# Define physical ethernet interface to be bridged
# with TAP interface(s) above.
eth="eth0"
eth_ip="192.168.0.140"
eth_netmask="255.255.255.0"
eth_broadcast="192.168.0.255"
for t in $tap; do
openvpn --mktun --dev $t
done
brctl addbr $br
brctl addif $br $eth
for t in $tap; do
brctl addif $br $t
done
for t in $tap; do
ifconfig $t 0.0.0.0 promisc up
done
ifconfig $eth 0.0.0.0 promisc up
ifconfig $br $eth_ip netmask $eth_netmask broadcast $eth_broadcast
</code></pre>
<p>where 192.168.0.140 is the IP address reserved to this server by the router's DHCP. The router (192.168.0.1) is used to access the Internet.</p>
<p>When I run the script everything seems fine from inside the LAN.
However, all the ports that were forwarded in the router to 192.168.0.140 suddenly stop answering.</p>
<p>I've noticed that router's DHCP uses MAC address to identify server, and that <code>br0</code> has a different MAC than <code>eth0</code>. So I added</p>
<pre><code>ifconfig $br hw ether d0:50:99:3b:4e:ff
</code></pre>
<p>at the end of the bridging script to make the <code>br0</code> have the same MAC as <code>eth0</code>. And it actually does assign the 'correct' MAC to <code>br0</code>, but, unfortunately, doesn't solve the problem.</p>
<p>The problem seems to be in the router itself, because the server still can be accessed from LAN.</p>
| 0non-cybersec
| Stackexchange | 600 | 1,763 |
I am having an affair with my married cousin. [No Regrets]
Although we are first cousins, we first met in my early 20s when she moved to the city where I worked. We hit it off right away, and stared "dating" in six months. After 2 years she "broke-up" with me (mostly because of the taboo nature of our relationship) and moved to another city 1000 miles away. There she started seeing someone, and got married to him eventually.
After about 8 years, life took me to that city. We decided to meet up (after all we are family), and what you know the spark is still there. | 0non-cybersec
| Reddit | 147 | 578 |
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 | 349 | 1,234 |
Decimal binary sequences that cannot be greater than 1. <p>Consider the family of sequences of the form $.012\ldots n$ for any natural number $n$. So, the sequences in this family are: $.01, .012, .0123, .01234,$ etc. </p>
<p>Now consider to manipulate each sequence in this way: </p>
<p>1) Start from the rightmost digit; let's say that the rightmost digit is $n$;<br>
2) If $n$ is even, replace $n$ by $0$ and add $n/2$ to the digit immediately on the left;<br>
3) if $n$ is odd, replace $n$ by $1$ and add $(n-1)/2$ to the digit immediately on the left;<br>
4) keep on modifying the sequence on the left until the only digits are '$0$' and '$1$'.</p>
<p>E.g., suppose that you consider the sequence $.01234.$ Then you modify it in this way: $.01250; .01410; .03010; .11010$.</p>
<p>I want to show that, for any $n$, after rewriting the sequence with only '$0$' and '$1$', I will never obtain any sequence that starts in this way $x.yy$'$y$'... where $x\neq 0$. So, e.g., I will never obtain any sequence like $1.0101$. </p>
<p>This problem is probably analogous to show that any sequence of the form $(0*2^{-1})+(1*2^{-2})+(2*2^{-3})+...+(n*2^{-(n+1)})$ is $<1$. However, I am not sure how to prove it.</p>
| 0non-cybersec
| Stackexchange | 410 | 1,222 |
Startup script is not running. <p>I am using Ubuntu 20.04LTS and I'm trying to run a script at startup. I created it in /etc/init.d/, gave it chmod 755 and ran the update-rc.d defaults command but the program is not executed on my next boot.Here is my script</p>
<pre><code>#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
sudo /opt/lampp/lampp start
google-chrome
code
echo "Script run successfully"
exit 0
</code></pre>
<p>When i try to run the script directly</p>
<pre><code>sudo service myscript.sh start
</code></pre>
<p>I get this message</p>
<pre><code>● myscript.service
Loaded: loaded (/etc/init.d/myscript.sh; generated)
Active: failed (Result: exit-code) since Sat 2020-07-18 14:00:39 +06; 3min 31s ago
Docs: man:systemd-sysv-generator(8)
Process: 12057 ExecStart=/etc/init.d/myscript.sh start (code=exited, status=1/FAILURE)
Tasks: 39 (limit: 9344)
Memory: 126.7M
CGroup: /system.slice/myscript.service
├─12112 /opt/lampp/bin/httpd -k start -E /opt/lampp/logs/error_log -DSSL -DPHP
├─12117 /opt/lampp/bin/httpd -k start -E /opt/lampp/logs/error_log -DSSL -DPHP
├─12209 /bin/sh /opt/lampp/bin/mysqld_safe --datadir=/opt/lampp/var/mysql --pid-file=/opt/lampp/var/mysql/GraceHopper.pid
├─12226 /opt/lampp/bin/httpd -k start -E /opt/lampp/logs/error_log -DSSL -DPHP
├─12227 /opt/lampp/bin/httpd -k start -E /opt/lampp/logs/error_log -DSSL -DPHP
├─12228 /opt/lampp/bin/httpd -k start -E /opt/lampp/logs/error_log -DSSL -DPHP
├─12229 /opt/lampp/bin/httpd -k start -E /opt/lampp/logs/error_log -DSSL -DPHP
├─12230 /opt/lampp/bin/httpd -k start -E /opt/lampp/logs/error_log -DSSL -DPHP
└─12358 /opt/lampp/sbin/mysqld --basedir=/opt/lampp --datadir=/opt/lampp/var/mysql --plugin-dir=/opt/lampp/lib/mysql/plugin/ --user=mysql --log-error=/opt/lampp/var/mysql/GraceHopper.err --pid-file=/opt/lampp/var/mysql/GraceHopper.pid --socket=/opt/lampp/var/mysql/mysql.sock --port=3306
Jul 18 14:00:39 GraceHopper myscript.sh[12113]: XAMP
Jul 18 14:00:39 GraceHopper myscript.sh[12080]: XAMP
Jul 18 14:00:39 GraceHopper myscript.sh[12080]: AMPP: Starting MySQ
Jul 18 14:00:39 GraceHopper sudo[12058]: pam_unix(sudo:session): session closed for user root
Jul 18 14:00:39 GraceHopper myscript.sh[12124]: AMPP
Jul 18 14:00:39 GraceHopper myscript.sh[12131]: AMPP
Jul 18 14:00:39 GraceHopper systemd[1]: myscript.service: Control process exited, code=exited, status=1/FAILURE
Jul 18 14:00:39 GraceHopper systemd[1]: myscript.service: Failed with result 'exit-code'.
Jul 18 14:00:39 GraceHopper systemd[1]: Failed to start myscript.service.
Jul 18 14:00:41 GraceHopper myscript.sh[12131]: 12125:12125:0718/140039.216854:ERROR:zygote_host_impl_linux.cc(89)] Running as root without --no-sandbox is not supported. See https://crbug.com/6381
</code></pre>
| 0non-cybersec
| Stackexchange | 1,164 | 3,170 |
Artin chapter 2 exercises. <p>I've written some solutions to Artin's exercises. Can someone please verify them?</p>
<blockquote>
<p>Assume the equation $xyz = 1$ holds for a group $G$. Does it follow that $yzx=1$? That $yxz=1$?</p>
</blockquote>
<p>We first show that $yzx = 1$:
\begin{eqnarray}
xyz&=&1 \\
yz&=&x^{-1} \\
yzx&=&x^{-1}x \\
yzx&=&1
\end{eqnarray}</p>
<p>We then show that $yxz \neq 1$, unless $x$ and $z$ commute:</p>
<p>\begin{eqnarray}
xyz &=&1\\
yz&=&x^{-1}\\
y&=&x^{-1}z^{-1}\\
yxz&=&x^{-1}z^{-1}xz\\
yzx&=&(zx)^{-1}(xz)
\end{eqnarray}</p>
<blockquote>
<p>Let $S$ be any set. Prove that the law of composition defined by $ab=a$ is associative.</p>
</blockquote>
<p>Let $a,b,c \in S$. Then,</p>
<p>\begin{equation}
a(bc)=ab=a
\end{equation}
Also,
\begin{equation}
(ab)c=ac=a
\end{equation}</p>
<blockquote>
<p>Determine the elements of the cyclic group generated by $\begin{bmatrix}
1 & 1 \\
-1 & 0
\end{bmatrix}$ explicitly.</p>
</blockquote>
<p>$H = \left\{\begin{bmatrix} 1 & 1 \\ -1 & 0 \end{bmatrix}, \begin{bmatrix} 0 & 1 \\ -1 & -1 \end{bmatrix}, \begin{bmatrix} -1 & 0 \\ 0 & -1 \end{bmatrix}, \begin{bmatrix} -1 & -1 \\ 1 & 0 \end{bmatrix}, \begin{bmatrix} 0 & -1 \\ 1 & 1 \end{bmatrix}, \begin{bmatrix} 1 & 0 \\ 0 & 1 \end{bmatrix}\right\}$</p>
<blockquote>
<p>Let $a,b$ be elements of an abelian group of orders $m$ and $n$, respectively. What can you say about the order of their product $ab$?</p>
</blockquote>
<p>The order of $ab$ is the least common multiple of $m$ and $n$.</p>
| 0non-cybersec
| Stackexchange | 684 | 1,660 |
Using async instead of Task.Run(). <p>I have the following piece of code:</p>
<pre class="lang-cs prettyprint-override"><code>private void btnAction_Click(object sender, RoutedEventArgs e)
{
/** Clear the results field */
txtResult.Text = "";
/** Disable the button and show waiting status */
btnAction.IsEnabled = false;
lblStatus.Text = "Wait...";
/** Get input from the query field */
string input = query.Text;
/** Run a new task */
Task.Run(() => {
// calling a method that takes a long time (>3s) to finish and return
var attempt = someLibrary.doSomethingWith(input);
// return the result to the GUI thred
this.Dispatcher.Invoke(() =>
{
if (attempt.ContainsKey("success"))
{
if (attempt["success"] == true)
{
txtResult.Text = "Success! The door is: " + (attempt["is_open"] ? "open" : "closed");
lblStatus.Text = "";
}
else
{
lblStatus.Text = "Error! The service says: " + attempt["errorMessage"];
}
}
else
{
MessageBox.Show("There was a problem getting results from web service.");
lblStatus.Text = "";
}
/** Re-enable the button */
btnAction.IsEnabled = true;
});
});
}
</code></pre>
<p>Now, I would like to: </p>
<ul>
<li>Write the same code in a way that uses a callback instead of using <code>Dispatcher.Invoke()</code>.</li>
<li>Be able to cancel a running task that calls <code>doSomething()</code></li>
<li>Be able to chain multiple calls, i.e. await <code>doSomething()</code> and after it finished, <code>doAnotherThing()</code> with the results from the previous call</li>
</ul>
<p>Hence why I want to write this using the async model.</p>
<p>What do I do?</p>
| 0non-cybersec
| Stackexchange | 537 | 1,975 |
Solving a Linear Constant Coefficient Difference Equation?. <p>I have the following difference equation:
<span class="math-container">$$y[n] + \alpha y[n-1] = \beta^nu[n]$$</span>
with <span class="math-container">$-1 < \alpha < 1$</span> and <span class="math-container">$-1 < \beta < 1$</span>. It is given <span class="math-container">$y[n] = 0$</span> for <span class="math-container">$n < 0$</span> and <span class="math-container">$u[n]$</span> is the unit step function. </p>
<p>I want to obtain the general solution.</p>
<p><strong>My attempt</strong>:</p>
<p><em>homogeneous solution</em>:
<span class="math-container">$$y_h[n] + \alpha y_h[n-1] = 0$$</span>
proposal: <span class="math-container">$y_h[n] = Ar^n$</span> and substitute into the above
<span class="math-container">$$Ar^n + A\alpha r^{n-1} = 0 \to Ar^{n-1}(r+\alpha) = 0$$</span>
or
<span class="math-container">$r = -\alpha$</span>, so the homogeneous solution is as follows:
<span class="math-container">$$y_h[n] = A(-\alpha)^n$$</span></p>
<p><em>particular solution</em>:</p>
<p>proposal: <span class="math-container">$y_p[n] = C\beta^n$</span> and using the governing equation:
<span class="math-container">$$C\beta^n + \alpha C \beta^{n-1} = \beta^n$$</span>
which can be solved for C:
<span class="math-container">$$C = \frac{\beta^n}{\beta^n + \alpha\beta^{n-1}} = \frac{\beta}{\beta+\alpha}$$</span>
which gives
<span class="math-container">$$y_p[n] = \frac{\beta}{\beta+\alpha}\beta^n = \frac{\beta^{n+1}}{\beta + \alpha}$$</span></p>
<p>and the general solution:
<span class="math-container">$$y[n] = A(-\alpha)^n + \frac{\beta^{n+1}}{\beta + \alpha}u[n]$$</span></p>
<p><strong>Question</strong>: </p>
<p>Is the above approach correct? </p>
<p>Especially the particular solution as I went from needing <span class="math-container">$\beta^n$</span> (current step) to <span class="math-container">$\beta^{n+1}$</span> (future step)</p>
| 0non-cybersec
| Stackexchange | 720 | 1,947 |
De Morgan's Law proof?. <p>The proof for <code>(A ∪ B)' = (A' ∩ B')</code> is:</p>
<p>Let's say <code>x ∈ (A ∪ B)'</code>. This means <code>x ∉ (A ∪ B)</code>, <code>x ∉ A and x ∉ B</code>. So, <code>x ∈ A' and x ∈ B'</code>. So <code>x ∈ (A' ∩ B')</code></p>
<p>So <code>(A ∪ B)' ⊆ (A' ∩ B')</code>. Then we have to prove <code>(A' ∩ B') ⊆ (A ∪ B)'</code> and we are done.</p>
<p>Can someone please explain why we write <code>(A ∪ B)' ⊆ (A' ∩ B')</code> and not <code>(A ∪ B)' = (A' ∩ B')</code>?</p>
| 0non-cybersec
| Stackexchange | 251 | 509 |
Why is the icon I've placed into /usr/share/icons not displaying in the MATE Applications menu?. <p>I have a <code>.desktop</code> file in <code>/usr/share/applications</code> with the entry:</p>
<pre><code>[Desktop Entry]
Icon=my-app
...
</code></pre>
<p>I have placed <code>my-app.png</code> into <code>/usr/share/icons/hicolor/32x32/apps</code>.</p>
<p>The icon displays just fine for its entry in the MATE Application menu if I explicitly point it to the icon location:</p>
<pre><code>Icon=/usr/share/icons/hicolor/32x32/apps/my-app.png
</code></pre>
<p>But it doesn't work if I use the basename:</p>
<pre><code>Icon=my-app
</code></pre>
<p>Why is it failing with just the basename? This seems to be how other applications do it.</p>
<p>I am referencing the specifications from <a href="https://specifications.freedesktop.org/icon-theme-spec/icon-theme-spec-latest.html" rel="nofollow noreferrer">freedesktop.org</a>. My distro is Fedora 30.</p>
<p>This is testing for an RPM package so I am not looking for answers that direct me to place it anywhere in my home folder.</p>
| 0non-cybersec
| Stackexchange | 363 | 1,092 |
Multiple "rundll32.exe mhunk.dme" instances. Is my PC Infected with Something?. <p>So, I have this strange list of rundll32.exe
There are quite a lot of rows of it (see attached image) when I open the process tab in my task manager</p>
<p>I've already read the link here: <a href="https://security.stackexchange.com/questions/26115/multiple-running-instances-of-rundll32-exe">Multiple running instances of rundll32.exe</a></p>
<p>The patterns appeared to be in the cmd line column</p>
<blockquote>
<p>rundll32.exe mhunkw.dme,</p>
</blockquote>
<p>For example, in my screenshot you will see</p>
<blockquote>
<p>rundll32.exe mhunkw.dme,krvvjwa</p>
<p>rundll32.exe mhunkw.dme,oxvlyk</p>
<p>...</p>
<p>rundll32.exe mhunkw.dme,szswzunt</p>
</blockquote>
<p>the list goes on.
Any idea what this is?<img src="https://i.stack.imgur.com/XJTH2.jpg" alt="enter image description here" /></p>
| 0non-cybersec
| Stackexchange | 343 | 891 |
Is there a way to do layer 7 filtering in Linux?. <p>The L7-filter project appears to be 15 years old, requires kernel patches with no support for kernels past version 2.6, and most of the pattern files it has appear to have been written in 2003.</p>
<p>Usually when there's a project that is that old, and that popular, there are new projects to replace it, but I can't find anything more recent for Linux that does layer 7 filtering.</p>
<p>Am I not looking in the right places? Was the idea of layer 7 filtering abandoned entirely for some reason? I would think that these days, with more powerful hardware, this would be even more practical than it used to be.</p>
| 0non-cybersec
| Stackexchange | 162 | 671 |
test for existing directory passes for directory that does not exist. <h3>Action</h3>
<p>I have set an environment variable in a user profile</p>
<pre><code>export DATADIR=<absolute path set with `readlink -e target`>
</code></pre>
<h3>Expected outcomes</h3>
<p>After sourcing the profile file again, I checked that it links to the target with</p>
<pre><code>echo ${DATADIR}; ls ${DATADIR}
</code></pre>
<p>which are a pass. If I do a test on whether</p>
<pre><code>test -d ${DATADIR} && echo yes || echo no
</code></pre>
<p>it is an <strong>expected pass</strong> as well (outcome 'yes')</p>
<h3>Unexpected outcomes</h3>
<p>However, if I give another directory name that has not been defined at all, say with any gibberish name, the test</p>
<pre><code>test -d ${HJIWEODSB} && echo yes || echo no
</code></pre>
<p>also give me a yes, that is an <strong>unexpected pass</strong>, since this name is no file and no directory.</p>
<h3>Expected outcomes again</h3>
<p>Actually also</p>
<pre><code>test -d && echo yes || echo no
</code></pre>
<p>gives yes, which makes me think that it refers to the current directory in the same way as <code>ls</code></p>
<h2>Question</h2>
<p>I have had a look at the man pages of test and to this page on <a href="https://www.lifewire.com/test-linux-command-unix-command-4097166" rel="nofollow noreferrer">Lifewire</a>.
Probably I am overlooking something them.
In sum, I need a robust test for the existence of a directory.
Corrections and tips welcome.</p>
<hr />
<p>Feel free to downvote of course. However, any suggestion about why this is not useful or is unclear or shows no research effort will be appreciated anyhow.</p>
| 0non-cybersec
| Stackexchange | 550 | 1,692 |
Using fetch to render json data in react app. <p>I am trying to render some JSON about a person's location from an api in my react app.</p>
<p>I am using <strong>isomorphic-fetch</strong> to access the data from the API I can add the base test in and it correctly logs the data using below.</p>
<pre><code> require('isomorphic-fetch');
require('es6-promise').polyfill();
var url = 'http://localhost:3000/api/data'
fetch(url)
.then(function(response) {
if (response.status >= 400) {
throw new Error("Bad response from server");
}
return response.json();
})
.then(function(data) {
console.log(data);
});
</code></pre>
<p>What i'm trying to work out is how I can take this response and render it in my component which currently looks like this (in this example code below data is coming from local json file so i need to merge them together).</p>
<p>I've attempted to set up componentDidMount but could get my head around the syntax so it kept breaking, I also checked out redux actions but that exploded my brain.</p>
<pre><code>const personLoc = Object.keys(data.person.loc).map((content, idx) => {
const items = data.person.loc[content].map((item, i) => (
<p key={i}>{item.text}</p>
))
return <div key={idx}>{items}</div>
})
export default function PersonLocation() {
return (
<div className="bio__location">
{personLoc}
</div>
)
}
</code></pre>
| 0non-cybersec
| Stackexchange | 456 | 1,493 |
Prove that AVL tree has this kind of property with Fibonacci sequence. <p>Q: Prove that for any AVL tree that has <span class="math-container">$n$</span> nodes (<span class="math-container">$n\geq 1$</span>)<br>
and has a height of <span class="math-container">$h$</span> this property is true:<br>
<span class="math-container">$n \geq F(h)$</span> where <span class="math-container">$F(h)$</span> is the <span class="math-container">$h$</span>-th element in the Fibonacci sequence:<br>
<span class="math-container">$F(0) =0, F(1)=1, F(n) = F(n-1) + F(n-2) ~~~~\forall n \geq 2$</span> </p>
<p>This is my go: </p>
<p>We know it is an AVL tree so <span class="math-container">$h = \log_2{n}$</span><br>
Thus we need to prove that <span class="math-container">$n \geq F( \log_2{n})$</span> </p>
<p><span class="math-container">$F(\log_2{n})= F(\log_2{n}-1)+F(\log_2{n}-2)$</span><br>
However I am stuck from here, I don't know what this helps me with and I am clueless on what to do next..<br>
I would appreciate your help, thank you!</p>
| 0non-cybersec
| Stackexchange | 398 | 1,044 |
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 | 349 | 1,234 |
Pollard's Kangaroo-- What is the failure probability (assuming random functions)?. <p>I'm reading Pollard's <a href="https://www.ams.org/journals/mcom/1978-32-143/S0025-5718-1978-0491431-9/S0025-5718-1978-0491431-9.pdf" rel="nofollow noreferrer">paper</a> on solving the discrete log problem, i.e. to find <span class="math-container">$x$</span> given <span class="math-container">$y = g^x$</span>, where <span class="math-container">$g$</span> is a generator of the group.</p>
<p>He has a Kangaroo Algorithm (page 4) which allows you, if you know that <span class="math-container">$x$</span> is in a range of size <span class="math-container">$w$</span>, to find <span class="math-container">$x$</span> in time <span class="math-container">$O (\sqrt{w})$</span> and constant space. Very cool. This algorithm is also well described on the <a href="https://en.wikipedia.org/wiki/Pollard%27s_kangaroo_algorithm" rel="nofollow noreferrer">Wikipedia page</a>.</p>
<p>There doesn't seem to be a complete analysis of the failure probability, though. For instance, if the size of the set, <span class="math-container">$|S|=1$</span>, then each hop will be of the same length, and so the "wild kangaroo" has a pretty good chance of escaping all the traps. So it seems that the size of the set should affect the failure probability, but this parameter does not seem to appear in any of the analysis (except maybe in some examples on page 6).</p>
<p>Is there a good analysis of the failure probability of this protocol? Also what set <span class="math-container">$S$</span> is good in practice? Pollard suggests powers of 2 but this is based on a fairly small set of possible <span class="math-container">$S$</span> he looked at--has any analysis since Pollard's original paper confirmed that this is a good choice of <span class="math-container">$S$</span>?</p>
| 0non-cybersec
| Stackexchange | 557 | 1,860 |
Integral curves are horizontal. <p>Suppose we're given an Ehresmann connection on a submersion (or a fiber bundle, but I don't think it's needed) <span class="math-container">$\begin{smallmatrix}X\\
\downarrow\\
Y
\end{smallmatrix}$</span>. Given a curve <span class="math-container">$\gamma$</span> in the base <span class="math-container">$Y$</span>, consider the pullback of the submersion and its connection along the curve. The horizontal bundle of the pulled-back bundle <span class="math-container">$\begin{smallmatrix}\gamma ^{\ast}X\\
\downarrow\\
I
\end{smallmatrix}$</span> is a line subbundle of the tangent bundle <span class="math-container">$\begin{smallmatrix}\mathrm T\gamma^{\ast}X\\
\downarrow\\
\gamma^\ast X
\end{smallmatrix}$</span>. Thus we locally have integral curves in <span class="math-container">$\gamma^\ast X$</span> for the horizontal bundle. These integral curves are also transverse to the fibers of the bundle <span class="math-container">$\gamma^\ast X\to I$</span>. </p>
<p>Write <span class="math-container">$c_{(s,x)}(t)\in \gamma^\ast X$</span> for the value of at <span class="math-container">$t$</span> of the integral curve <span class="math-container">$c$</span> based at <span class="math-container">$(s,x)\in \gamma^\ast X$</span>. How can I prove the first coordinate of <span class="math-container">$c_{(s,x)}(t)$</span> is always <span class="math-container">$s+t$</span>? I drew a picture, which tells me I should use transversality, but I don't know how to formulate a proof.</p>
<p>(The context: I want to prove that flow along the horizontal bundle defines parallel transport, and for that I need to know the horizontal position of an integral curve at each instance.)</p>
| 0non-cybersec
| Stackexchange | 491 | 1,728 |
Combinatorics Question with limitations. <ol>
<li>$n$ men $\rightarrow n \in N$</li>
<li>$n$ women $\rightarrow n \in N$</li>
<li>$n$ childs $\rightarrow n \in N$
<br></li>
</ol>
<p>How many ways we can order them:( lets say in row )<br></p>
<ol>
<li>without limit</li>
<li>1 man and 1 woman can`t sit togather</li>
<li>each group sit togather, women, men , childs</li>
<li>2 kids cannot sit togather</li>
<li>between 1 man and 1 women there is at least $3n-3$ people</li>
</ol>
<p>what I did so far is: ( my answers for each question )<br></p>
<ol>
<li>$(n!)^3$</li>
<li>$\binom {n} {n-2} \cdot ((n-1)!)^2 \cdot n!$</li>
<li>$(n!)^3\cdot (3!)$</li>
</ol>
<p>for the two other I would like to get some advice, and for what I answered comments.<br>
thanks!</p>
| 0non-cybersec
| Stackexchange | 320 | 767 |
MVC4 enum and radio button list. <p>I have seen a few threads on this but none seem to apply to MVC4 because the RadioButtonFor html extension method/helper does not exist.</p>
<p>Say I have an enum list - i.e Airlines:</p>
<pre><code>public enum Airlines
{
Unknown = 0,
BritishAirways = 1,
VirginAtlantic = 2,
AirFrance = 3
}
</code></pre>
<p>How can I bind this to a Radio button list on my view and be able to retrieve the selected item?
What about being able to say "select one item" if there is no selection made? </p>
| 0non-cybersec
| Stackexchange | 163 | 539 |
Showing that all monotone functions are integrable. <p>I am given the following proof:</p>
<p>Theorem. All monotone functions are integrable.</p>
<p>Proof. Without loss of generality, assume that $f$ is increasing on an interval $\left[a, b \right]$.
Thus, $f(a) \le f(x) \le f(b)$, and $f$ is bounded on $\left[a, b \right]$.
Given $\varepsilon >0$, there exists $k > 0$ such that</p>
<p>\begin{equation*}
k \left[f(b) - f(a) \right] < \varepsilon.
\end{equation*}</p>
<p>Let $P = \left\lbrace x_0, x_1, \dots, x_n \right\rbrace$ be a partition of $\left[a, b \right]$ such that $\Delta x_i \le k$ for all $i$. Since $f$ is increasing, it follows that</p>
<p>\begin{equation*}
m_i = f(x_{i-1}) \ \text{and} \ M_i = f(x_i), \quad i = 1, 2, \dots, n.
\end{equation*}</p>
<p>Where $m_i$ is the greatest lower bound of $f$ on $\left[ x_{i-1}, x_i \right]$, and $M_i$ is the least upper bound of $f$ on $\left[ x_{i-1}, x_i \right]$.</p>
<p>$U(f, P) - L(f, P) = \sum_{i=1}^n \left[ f(x_i) - f(x_{i-1}) \right] \Delta x_i$</p>
<p>$\le k \sum_{i=1}^n \left[ f(x_i) - f(x_{i-1}) \right] (*)$</p>
<p>$= k \left[f(b) - f(a) \right] $</p>
<p>$< \varepsilon.$</p>
<p>By Theorem 7.1.9 $f$ is integrable on $\left[ a, b \right]$. In the case that $f$ is monotone decreasing, we may use the same argument on $-f$.</p>
<p>I am just wondering if somebody could explain how we get from the line marked by (*) to the line after that.</p>
| 0non-cybersec
| Stackexchange | 598 | 1,446 |
HTML Form: POST an array of objects. <p>Submitting a class roster. Adding 3 students at once. Each student has first, last, age. </p>
<p><strong>Question:</strong> How can we get all of the students in an array of arrays? </p>
<pre><code>students[0] => Array (
["first"] => "first name for 0",
["last"] => "last name for 0",
["age"] => "age for 0"
),
students[1] => Array (
["first"] => "first name for 1",
["last"] => "last name for 1",
["age"] => "age for 1"
),
...
</code></pre>
<p><strong>Details</strong><br>
For one student: </p>
<pre><code><input type="text" name="first">
<input type="text" name="last">
<input type="text" name="age">
</code></pre>
<p>We can return multiple students in separate arrays like this: </p>
<pre><code><input type="text" name="students[first][]">
<input type="text" name="students[last][]">
<input type="text" name="students[age][]">
</code></pre>
<p>which returns an array of firsts, lasts and ages </p>
<pre><code>students["first"] = [array of first names]
students["last"] = [array of last names]
students["age"] = [array of ages]
</code></pre>
<p>Theoretically we can get all the info for a student by accessing the same index (say "3" for each array). </p>
<p>We do not want to programatically add an index in the form.<br>
Do not want: </p>
<pre><code><input type="text" name="students[hardcoded_index][first]">
<input type="text" name="students[hardcoded_index][last]">
<input type="text" name="students[hardcoded_index][age]">
</code></pre>
<p>If for any reason it matters, we are using Rails for views but can use form helpers or HTML.</p>
| 0non-cybersec
| Stackexchange | 628 | 1,720 |
What disables Gradual Overflow?. <p>After studying the process of <a href="http://books.google.com.au/books?id=EV_Ojz00A9IC&pg=PA44&lpg=PA44&dq=why%20is%20there%20no%20gradual%20overflow&source=bl&ots=APOQj-ThVm&sig=ohKLKH89V7Iq-8sXmEVzt-n93nk&hl=en&sa=X&ei=bUnkU4jjG9iE8gXn74DgBg&ved=0CBsQ6AEwADgK#v=onepage&q&f=false" rel="nofollow" title="Gradual Underflow">Gradual Underflow</a>, I'm left a little curious as to why machines don't implement <em>Gradual Overflow</em>; where numbers exceeding the overflow level would be stored as un-normalized floats.<br>
Just as the precision of the <a href="http://en.wikipedia.org/wiki/Significand" rel="nofollow" title="mantissa">mantissa</a> is decreased for representation of a larger (in magnitude) exponent (and thus a smaller number in scientific notation) for <a href="http://en.wikipedia.org/wiki/Denormal_number" rel="nofollow" title="subnormal numbers">subnormal numbers</a>, so too could precision be traded for numbers above the overflow.</p>
<p>The only conceivable reason I can place for this is based on number format preservation during gradual underflow; the mantissa digits are 'right-shifted' (preceding zeros are adding after the decimal point) so although the representation is no longer normalized, it still consists of a single digit before the decimal point and the same storage spaces of mantissa and exponent.<br>
The best conception of a Gradual Overflow implementation I can muster would involve either expanding the exponent storage space (at the cost of mantissa storage space and thus precision), or 'right-shifting' the decimal point down the mantissa (again, a loss of mantissa precision). This would seemingly break the mantissa format of a single digit before the decimal point (or otherwise change the mantissa / exponential allocated storage spaces). </p>
<p>I suppose I can understand that in a binary representation (with no delimiters between representation components (ie sign, mantissa, etc); distinction only made via the constant lengths of the components), breaking the storage pattern as Gradual Overflow would require is unsupportable. This assumes that there isn't a better implementation than the one I personally conceived that can preserve the storage pattern.</p>
<p>Is this line of thinking correct, or is there a more pertinent reason as for the lack of Gradual Overflow?<br>
Thanks! </p>
<p><strong><em>(I can't really tag this appropriately, since there is a rather small pool of existing tags and I don't have the reputation to create any)</em></strong></p>
| 0non-cybersec
| Stackexchange | 708 | 2,610 |
Brachistochrone Problem with friction. <p>I found in "Wolfram Math world" this equation of motion for a</p>
<p>Brachistochrone Problem with friction</p>
<p><span class="math-container">$$\left[1+y'^2\right]\,(1+\mu\,y')+2(y-\mu\,x)\,y''=0$$</span></p>
<p>this can reduced to:</p>
<p><span class="math-container">$$\frac{1+y'^2}{(1+\mu\,y')^2}=\frac{C}{y-\mu\,x}\tag 1$$</span></p>
<p><strong>First question:</strong></p>
<p>if I use the Beltrami equation i don't get this equation ? so where this equation come from ?</p>
<p>The solution that i found in "Wolfram Mathworld" </p>
<p><span class="math-container">$$x=\frac{1}{2}\,k^2\left[(\theta-\sin(\theta))+\mu(1-\cos(\theta))\right]$$</span></p>
<p>and</p>
<p><span class="math-container">$$y=\frac{1}{2}\,k^2\left[(1-\cos(\theta))+\mu(\theta+\sin(\theta))\right]$$</span></p>
<p>doesn't satisfied equation (1) , why not? </p>
| 0non-cybersec
| Stackexchange | 355 | 894 |
Finite ring extensions doesn't preserve non-zero-divisors. <p>Can you give an example of a finite ring extension <span class="math-container">$A \hookrightarrow B$</span> of noetherian rings <span class="math-container">$A,B$</span> which maps a non-zero-divisor to a zero-divisor.</p>
<p>Background: In this case <span class="math-container">$A \hookrightarrow B$</span> does not induce a homomorphism <span class="math-container">$Q(A) \to Q(B)$</span> of total quotient rings.</p>
| 0non-cybersec
| Stackexchange | 151 | 489 |
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 | 349 | 1,234 |
Wkhtmltopdf margin (top and bottom). <p>I am using wkhtmltopdf 0.10.0 rc2 on a: Linux 3.2.0-24-generic #38-Ubuntu x86_64 GNU/Linux</p>
<p>I can't create PDFs with <code>margin-top</code> or <code>margin-bottom</code> (no errors)</p>
<p>I'm using the command below:</p>
<pre><code>wkhtmotopdf -T 50 -B 50 http://google.com ./test.pdf
wkhtmotopdf --margin-top 50 --margin-bottom 50 page.html ./test.pdf
</code></pre>
<p>When I try this:</p>
<pre><code>wkhtmotopdf -L 50 -R 50 -T 50 -B 50 page.html ./test.pdf
</code></pre>
<p>Margin left and right works perfect (still no margin-top or margin-bottom). It doesn't matter which URL or page I convert.</p>
<h2>EDIT:</h2>
<p>It looks like it's a bug. For the people who still want some margin-top/margin-bottom.
Try using the header-html/footer-html feature:</p>
<blockquote>
<blockquote>
<p>Just realised that the clipping problem is fixed by adding the header-spacing and footer-spacing parameters:</p>
</blockquote>
</blockquote>
<p><code>wkhtmotopdf -L 50 -R 50 -T 50 -B 50 http://google.com --header-html blank.html --header-spacing 5 --footer-html blank.html --footer-spacing 5 ./test.pdf</code></p>
| 0non-cybersec
| Stackexchange | 417 | 1,168 |
Convention for labeling vertices of quadrilaterals.. <p>I am wondering if there is a convention for labeling the vertices of various quadrilaterals ABCD etc.</p>
<p>For example ABCD is a parallelogram. E is a point on DC extended, such that D and E are on opposite sides of BC. </p>
<p>Normally I put A in the top left then B in the top Right then C in the bottom left then D in the bottom right but it seems sometimes this results in incorrect construction.</p>
<p>Thanks!</p>
| 0non-cybersec
| Stackexchange | 133 | 481 |
Backup all pictures without iTunes. <p>My mother's iPhone has collected over 1000 family pictures from the camera, emails and WhatsApp. I am definitely <em>not</em> an Apple guy and I don't know where to even begin. </p>
<p>I'd like to save all the pictures on my computer and delete them off the phone. This will help me backup the pictures + create space on the iPhone.</p>
<p>What is the simplest way to do this without installing iTunes? </p>
<p>I do not have a MacBook or any laptop with Apple operating system on it. I do have an iPad though.</p>
| 0non-cybersec
| Stackexchange | 148 | 556 |
Why does does SSE set (_mm_set_ps) reverse the order of arguments. <p>I recently noticed that </p>
<pre><code>_m128 m = _mm_set_ps(0,1,2,3);
</code></pre>
<p>puts the 4 floats into reverse order when cast to a float array:</p>
<pre><code>(float*) p = (float*)(&m);
// p[0] == 3
// p[1] == 2
// p[2] == 1
// p[3] == 0
</code></pre>
<p>The same happens with a <code>union { _m128 m; float[4] a; }</code> also.</p>
<p>Why do SSE operations use this ordering? It's not a big deal but slightly confusing. </p>
<p><strong>And a follow-up question:</strong></p>
<p>When accessing elements in the array by index, should one access in the order <code>0..3</code> or the order <code>3..0</code> ?</p>
| 0non-cybersec
| Stackexchange | 269 | 702 |
Existence of limits. <p>$ \lim_{x \to x_0^-} f(x) $ exists and is finite $\iff $ $ \forall \epsilon > 0, \exists \delta > 0 $ such that $ x_0 - \delta < x_1, x_2 < x_0 \implies |f(x_1) - f(x_2) | < \epsilon $</p>
<p>I believe I have proven the forward direction using an $ \frac{\epsilon}{2} $ argument. For the backwards direction, I think I need to show that the left limit superior and left limit inferior are equal, but I'm not sure how to go about showing that $f$ is bounded first.</p>
| 0non-cybersec
| Stackexchange | 177 | 511 |
Vim - up-down line movements the cursor changes column position. <p>While editing a simple text file where every line is nearly to the end of screen, I was expecting vim to retain the column position as I used j and k to move up and down.</p>
<p>Surprisingly, it does not happen. I am using a default install of vim on ubuntu 12.10 and a few plugins (unicycle, speeddating, tex, Align, Alignmaps, genutils, html, foldutil, scratch, surround).</p>
<p>The behaviour I am referring to is: I am in C57-L5. Line 6 is 80 characters long. I hit j, cursor jumps to C1-L6 instead of C57-L6.</p>
<p>What could be wrong? How can I set it right?</p>
| 0non-cybersec
| Stackexchange | 195 | 641 |
trace apache access_log file record called by which html or php file. <p>I figured out that my access_log have funny records</p>
<pre><code>118.101.120.86 - - [20/Apr/2015:23:20:57 +0400] "\xed3.\xbd\xd5\xeb\x16\xca\xa4" 200 378
146.185.239.100 - - [20/Apr/2015:23:31:00 +0400] "GET http://24x7-allrequestsallowed.com/?PHPSESSID=a77ad01b00143PUVJWUGY%40G%5EJFQU HTTP/1.1" 200 378
113.210.128.99 - - [20/Apr/2015:23:32:35 +0400] "\xf1/v#\xd2\xd5\xef\xf7s\x962\xcbZ\x19p\xae\xc9(w2\xa0\x90" 200 378
</code></pre>
<p>How can I trace, which file they access to able to access the <a href="http://24x7-allrequestsallowed.com" rel="nofollow noreferrer">http://24x7-allrequestsallowed.com</a></p>
<p>I am very new in this area, but I would like to know which malicious file cause them to able to load this.</p>
<ol start="2">
<li>and I also how can I decode those <strong>\xf1/v#\xd2\xd5\xef\xf7s</strong> , any where can decode it?</li>
</ol>
| 0non-cybersec
| Stackexchange | 399 | 941 |
Dragon age: Origins DLC won't work - Help, pls. I bought the physical copy of Dragon Age: Origins that comes with two discs, the 2nd disc contains all of the DLC. It installs the DLC just fine, and the game starts up with everything in working order.
However, if I take the DLC disc out, the game will no longer register that the DLC is installed and will not let me load my save files. Even if I place the DLC disc back into the Xbox, from that point on it will no longer see the DLC unless I completely uninstall the game and then re-install it.
What can I do to fix this problem? | 0non-cybersec
| Reddit | 152 | 584 |
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 | 349 | 1,234 |
A specific Model of ZFC. <p>In his paper "<a href="http://jdh.hamkins.org/somesecondordersettheory/" rel="noreferrer">Some Second Order Set Theory</a>", Joel Hamkins asked whether there is a model of set theory $V$ that is elementary equivalent to $V[G]$, Whenever $G$ is $V$-generic for the collapse of a cardinal $\delta$ to $\omega$?
It seems that the existence of such a model will have large cardinal strength.
Assume such model exists, then ;</p>
<blockquote>
<p><em>1.There is no switches(a statement $\phi$ in language of set theory such that both $\phi$ and $\neg \phi$ can be forced by set forcing-here by collapse forcing)for collapse forcing over this model.</em></p>
<p><em>2. $\diamondsuit\phi \longleftrightarrow \phi \longleftrightarrow\square \phi$(By collapse forcing).</em></p>
<p><em>3. $V \models$ MP(Hamkins' maximality principle)</em></p>
</blockquote>
<p>Assume such a model exists, my questions are :</p>
<blockquote>
<p><strong>Question 1.</strong> What is valid principle for collapse forcing? Is it modal logic of provability?</p>
<p><strong>Question 2.</strong> What are other straightforward consequences?</p>
<p><strong>Question 3.</strong> In general, is this model strange? Is it ugly or no, it's nice? will we have nice consequences or not(not necessarily related to modal logic of forcing)?</p>
<p><strong>Question 4.</strong> Can this question be asked about other forcing notions, I mean are they interesting?</p>
</blockquote>
| 0non-cybersec
| Stackexchange | 431 | 1,497 |
Get intent filter for receivers. <p>I am trying to get a list of receivers that handle <code>android.intent.action.BOOT_COMPLETED</code> for other applications.</p>
<p>I can get only the apps with that action with this:</p>
<pre><code>final PackageManager pm = getPackageManager();
final Intent intent = new Intent("android.intent.action.BOOT_COMPLETED");
final List<ResolveInfo> activities = pm.queryBroadcastReceivers(intent, 0);
for (ResolveInfo ri : activities) {
Log.i(TAG, "app name: " + ri.loadLabel(pm));
}
</code></pre>
<p>I can get a list of receivers with this code:</p>
<pre><code>final List<PackageInfo> packs = pm.getInstalledPackages(PackageManager.GET_RECEIVERS);
for (final PackageInfo p : packs) {
ActivityInfo[] receivers = p.receivers;
if (receivers != null) {
for (ActivityInfo ai : receivers) {
Log.i(TAG, "receiver: " + ai.name);
}
}
}
</code></pre>
<p>After I get the receivers I cannot tell what the intent-filter/action is. If an app has two receivers I need to know which one handles <code>android.intent.action.BOOT_COMPLETED</code>. Is there a way I can get this info?</p>
| 0non-cybersec
| Stackexchange | 373 | 1,182 |
UDF performance suddenly degraded. <p>SQL Server 2008 R2</p>
<p>I know this is a common problem (eg: <a href="http://connect.microsoft.com/SQLServer/feedback/details/524983/user-defined-function-performance-is-unacceptable" rel="nofollow">http://connect.microsoft.com/SQLServer/feedback/details/524983/user-defined-function-performance-is-unacceptable</a>) - but ive only just learned of it.</p>
<p>We have a live production database that has performed fine for months, specifically a stored procedure that contains a large CTE that selects into a table variable. Then, based on a parameter on the procedure - data is selected from the table variable in various ways (column sequence, order by clause etc).</p>
<p>This temporary table only has a few hundred rows inserted into it from the CTE - the source data is huge, but the resulting rows are always low in number)</p>
<p>The select satements used on the table variable use 2 very simple UDF's:</p>
<pre><code>CREATE FUNCTION [dbo].[format_timeV2] ( @Time INT )
RETURNS VARCHAR(20)
AS
BEGIN
DECLARE @Time_Varchar VARCHAR(20)
SET @Time_Varchar = CONVERT(VARCHAR, @Time / 3600) + 'h ' + CONVERT(VARCHAR, ROUND(( ( CONVERT(FLOAT, ( @Time % 3600 )) ) / 3600 ) * 60, 0)) + 'm'
RETURN @Time_Varchar
END
GO
</code></pre>
<p>And</p>
<pre><code>CREATE FUNCTION [dbo].[udf_WeekEndDate] ( @Date DATETIME )
RETURNS DATETIME
AS
BEGIN
RETURN DATEADD(DAY, 7, CONVERT(DATETIME, CONVERT(VARCHAR(10), DATEADD(day, -1 - ( DATEPART(dw, @Date) + @@DATEFIRST - 2 ) % 7, @Date), 103) + ' 23:59:59', 103))
END
GO
</code></pre>
<p>These UDF's have been working fine for months, if not years, the stored procedure in question has ALWAYS ran in under 6 seconds - but as soon as the UDF's above are included on the SELECT statement of the table variable the procedure takes MINUTES!</p>
<p>As soon as we comment out the usage of these functions it returns to executing in 3-6 seconds.</p>
<p>These functions are only being used on the <code>SELECT</code> from <code>@TableVar</code> statement (few hundred rows) - so i dont see why the query optimiser if struggling here?!?!</p>
<p>If we run the following - the UDF's and procedure start to work normally again:</p>
<pre><code>DBCC FreeProcCache
DBCC DropCleanbuffers
</code></pre>
<p>So i can only assume the query optimiser is doing something stupid in the background - but it's not clear on the execution plan as to what it is.</p>
<p>I have tried recreating the proc with <code>RECOMPILE</code> - this didnt help, only <code>FreeProcCache</code> & <code>DropCleanbuffers</code> helped.</p>
<p>Any ideas what the root cause of this? we dont really want to go re-writing all the UDFs as table valued function (which i understand is a work around for this problem) as this is a live production database which has been working fine for years.</p>
<p><strong>EDIT 1:</strong> Blam requested detail of the actual query that hangs:</p>
<pre><code> IF @ModeInt = 2
SELECT [DET_NUMBERA] ,
[Name] ,
[Branch] ,
COUNT(*) OVER ( PARTITION BY [DET_NUMBERA] ) AS RowsForThisEmployee ,
CONVERT(VARCHAR(10), dbo.udf_WeekEndDate([Date]), 103) AS [WeekEnding] ,
[Date] ,
[Start Time] ,
[End Time] ,
[Duration] ,
dbo.format_timeV2([Duration] * 60) AS [DurationF] ,
[EntryCount] ,
[EntryColour] ,
[DurationColour] ,
[DurationComment]
FROM @CompletedData
WHERE [EntryCount] = 0
ORDER BY [DET_NUMBERA] ,
[Date] ,
[Start Time]
IF @ModeInt = 3
SELECT [DET_NUMBERA] ,
[Name] ,
[Branch] ,
COUNT(*) OVER ( PARTITION BY [DET_NUMBERA] ) AS RowsForThisEmployee ,
CONVERT(VARCHAR(10), dbo.udf_WeekEndDate([Date]), 103) AS [WeekEnding] ,
[Date] ,
[Start Time] ,
[End Time] ,
[Duration] ,
dbo.format_timeV2([Duration] * 60) AS [DurationF] ,
[EntryCount] ,
[EntryColour] ,
[DurationColour] ,
[DurationComment]
FROM @CompletedData
WHERE [EntryCount] > 1
ORDER BY [DET_NUMBERA] ,
[Date] ,
[Start Time]
</code></pre>
<p>The temp table doesnt have an index (didnt think it was needed as it only ever contains 100 - 200 rows:</p>
<pre><code> DECLARE @CompletedData TABLE
(
[DET_NUMBERA] VARCHAR(7) ,
[Name] VARCHAR(255) ,
[Branch] VARCHAR(3) ,
[Date] DATE ,
[Start Time] TIME(0) ,
[End Time] TIME(0) ,
[Duration] INT ,
[EntryCount] INT ,
[EntryColour] VARCHAR(15) ,
[DurationColour] VARCHAR(15) ,
[DurationComment] VARCHAR(65)
)
</code></pre>
<p>The CTE populates the table in 3 seconds, its only the above SELETS that make use of UDF's that hang, if i remove the UDF's from the SELECT it works instantly.</p>
| 0non-cybersec
| Stackexchange | 1,530 | 5,222 |
A special case of integrating over a marginal distribution. <p>Let $F(x \mid y, z)$ denote the conditional distribution of $x$ conditional on $y$ and $z$. Suppose that
\begin{equation}
\forall (y, y') \forall z, \quad F(x\mid y, z) = F(x\mid y', z).
\end{equation}</p>
<p>Is it the case that
\begin{equation}
\forall (y, y'), \quad F(x\mid y) = F(x\mid y')?
\end{equation}</p>
<p>The reason I ask is because I am reading a paper that assumes that $y$ and $z$ are independent in order to prove this result, but I feel that assumption is unnecessary. For example if $z$ is a continuous random variable, then for all $(y, y')$ we have
\begin{align}
F(x|y) &= \int_z F(x\mid y, z) \color{red}{f(z)} dz \\
&= \int_z F(x\mid y',z) \color{red}{f(z)} dz \\
&= F(x\mid y'),
\end{align}
$\color{red}{\text{Where $f$ is the marginal distribution of $z$.}}$</p>
<p>If $z$ is discrete, then let $I$ be an index set that is either finite or countably infinite. We have
\begin{align}
F(x|y) &= \sum_{i \in I} Pr(z=i)F(x|y, z=i) \\
&= \sum_{i \in I} Pr(z=i)F(x|y', z=i) \\
&= F(x|y')
\end{align}</p>
<p>We could treat random variables that are neither discrete nor continuous in the measure theoretic framework with a little extra notation.</p>
<p><strong>NOTE</strong> that the text in red was added in response to an answer, which highlighted a mistake in the original post.</p>
| 0non-cybersec
| Stackexchange | 518 | 1,412 |
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 | 349 | 1,234 |
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 | 349 | 1,234 |
How to set limits for axes in ggplot2 R plots?. <p>I plot the following:</p>
<pre><code>library(ggplot2)
carrots <- data.frame(length = rnorm(500000, 10000, 10000))
cukes <- data.frame(length = rnorm(50000, 10000, 20000))
carrots$veg <- 'carrot'
cukes$veg <- 'cuke'
vegLengths <- rbind(carrots, cukes)
ggplot(vegLengths, aes(length, fill = veg)) +
geom_density(alpha = 0.2)
</code></pre>
<p>Now say I only want to plot the region between <code>x=-5000</code> to <code>5000</code>, instead of the entire range.</p>
<p>How can I do that?</p>
| 0non-cybersec
| Stackexchange | 227 | 565 |
Applying style to Path inside ContentPresenter (BasedOn not working!). <p>I am unable to apply a MouseOver style to a Path inside a ContentPresenter.</p>
<p>I have a Button style containing a ContentPresenter:</p>
<pre><code><Style x:Key="ContentButton" TargetType="{x:Type Button}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Button}">
<ContentPresenter
x:Name="contentPresenter"
Content="{TemplateBinding Content}">
<ContentPresenter.Resources>
<Style TargetType="{x:Type Path}"
BasedOn="{StaticResource ContentButtonPathStyle}"/>
</ContentPresenter.Resources>
</ContentPresenter>
</code></pre>
<p>Here is a style so I can have a rollover effect on the Path:</p>
<pre><code><Style x:Key="ContentButtonPathStyle" TargetType="{x:Type Path}">
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Fill" Value="#FF00FF10"/>
<Setter Property="Stroke" Value="Red"/>
<Setter Property="StrokeThickness" Value="6"/>
</Trigger>
</Style.Triggers>
<Setter Property="Stroke" Value="Red"/>
<Setter Property="Fill">
<Setter.Value>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="#FFB4B3E7" Offset="0"/>
<GradientStop Color="#FF0800FF" Offset="1"/>
</LinearGradientBrush>
</Setter.Value>
</Setter>
</Style>
</code></pre>
<p>I also have a resource file for icons with a Viewbox that contains a path:</p>
<pre><code><Viewbox x:Key="MyIcon">
<Grid>
<Path Data="M78,296 L37.5,306.5 45.5,354.5 123.5,343.5 z" />
</Grid>
</Viewbox>
</code></pre>
<p>And finally, I create a button and assign the Viewbox resource to the Content:</p>
<pre><code><Button Style="{DynamicResource ContentButton}">
<ContentPresenter Content="{DynamicResource MyIcon}"/>
</Button>
</code></pre>
<p>The use of "BasedOn" to style the contents of the ContentPresenter is a technique that I found here:</p>
<p><a href="http://social.msdn.microsoft.com/forums/en-US/wpf/thread/412b1747-60e9-4b9a-8f8f-bd56f3aff875/" rel="noreferrer">http://social.msdn.microsoft.com/forums/en-US/wpf/thread/412b1747-60e9-4b9a-8f8f-bd56f3aff875/</a></p>
<p>However, it doesn't work for me... I've spent many hours trying to figure this out!</p>
<p>Any ideas?</p>
<p>Thanks!</p>
<hr>
<p>OK based upon Mackho's excellent answer, here is my final XAML.</p>
<p>I also added a DataTriggeer for IsPressed, which works great!</p>
<p>I hope this helps someone...</p>
<p>First, the style:</p>
<pre><code><Style x:Key="ContentButtonPathStyle" TargetType="{x:Type Path}">
<Style.Triggers>
<DataTrigger Binding="{Binding RelativeSource=
{RelativeSource Mode=FindAncestor, AncestorType={x:Type Button}}, Path=IsMouseOver}" Value="True">
<Setter Property="Fill" Value="Yellow"/>
<Setter Property="Stroke" Value="Blue"/>
</DataTrigger>
<DataTrigger Binding="{Binding RelativeSource=
{RelativeSource Mode=FindAncestor, AncestorType={x:Type Button}}, Path=IsPressed}" Value="True">
<Setter Property="Fill" Value="Red"/>
<Setter Property="Stroke" Value="Black"/>
</DataTrigger>
</Style.Triggers>
<Setter Property="Fill" Value="Green"/>
<Setter Property="Stroke" Value="Red"/>
</Style>
</code></pre>
<p>Next, the icon itself:</p>
<pre><code><Viewbox Stretch="Fill" x:Shared="False" x:Key="MyIcon">
<Path StrokeThickness="6" Data="M160.26077,0.5 L196.5,36.739223 232.73923,0.5 251.12399,18.884777 214.88478,55.124001 251.12399,91.363222 232.73923,109.748 196.5,73.508779 160.26077,109.748 141.87601,91.363222 178.11522,55.124001 141.87601,18.884777 z" Stretch="Fill"/>
</Viewbox>
</code></pre>
<p>Then, the template:</p>
<pre><code><Style x:Key="ContentButton" TargetType="{x:Type Button}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Button}">
<ControlTemplate.Resources>
<Style TargetType="{x:Type Path}" BasedOn="{StaticResource ContentButtonPathStyle}"/>
</ControlTemplate.Resources>
<Grid Background="Transparent"><ContentPresenter /></Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</code></pre>
<p>And finally, let's place a few buttons that use the template and style:</p>
<pre><code><Grid>
<Button Style="{DynamicResource ContentButton}" HorizontalAlignment="Left" Width="128" Height="128" VerticalAlignment="Top" Margin="85.5,87,0,0">
<ContentPresenter Content="{DynamicResource MyIcon}" d:IsLocked="True"/>
</Button>
<Button Style="{DynamicResource ContentButton}" Height="64" VerticalAlignment="Top" Margin="0,87,204.5,0" HorizontalAlignment="Right" Width="64">
<ContentPresenter Content="{DynamicResource MyIcon}" d:IsLocked="True"/>
</Button>
<Button Style="{DynamicResource ContentButton}" Height="96" VerticalAlignment="Bottom" Margin="234,0,0,66.5" HorizontalAlignment="Left" Width="96">
<ContentPresenter Content="{DynamicResource MyIcon}" d:IsLocked="True"/>
</Button>
<Button Style="{DynamicResource ContentButton}" Height="32" VerticalAlignment="Bottom" Margin="0,0,138.5,130.5" HorizontalAlignment="Right" Width="32">
<ContentPresenter Content="{DynamicResource MyIcon}" d:IsLocked="True"/>
</Button>
</Grid>
</code></pre>
| 0non-cybersec
| Stackexchange | 2,110 | 6,262 |
What's the fastest way to subset a data.table?. <p>It seems to me the fastest way to do a row/col subset of a <code>data.table</code> is to use the join and <code>nomatch</code> option.</p>
<p>Is this correct?</p>
<pre><code>DT = data.table(rep(1:100, 100000), rep(1:10, 1000000))
setkey(DT, V1, V2)
system.time(DT[J(22,2), nomatch=0L])
# user system elapsed
# 0.00 0.00 0.01
system.time(subset(DT, (V1==22) & (V2==2)))
# user system elapsed
# 0.45 0.21 0.67
identical(DT[J(22,2), nomatch=0L],subset(DT, (V1==22) & (V2==2)))
# [1] TRUE
</code></pre>
<p>I also have one problem with the fast join based on binary search: I cannot find a way to select all items in one dimension.</p>
<p>Say if I want to subsequently do:</p>
<pre><code>DT[J(22,2), nomatch=0] # subset on TWO dimensions
DT[J(22,), nomatch=0] # subset on ONE dimension only
# Error in list(22, ) : argument 2 is empty
</code></pre>
<p>without having to re-set the key to only one dimension (because I am in a loop and I don't want to rest the keys every time).</p>
| 0non-cybersec
| Stackexchange | 405 | 1,068 |
I had a date this night, got stood up. Tell me your 'bad date' story. We met thursday at the bar, i ducked in to charge my cell phone, she was there waiting for her train. We hit it off right away, kissed a little, she hung out talking to me until the last train of the night. I walked her to the station, we agreed to meet tonight at another bar in town on sunday(tonight)
She never showed.
I gave her my number, she never called to say she was running late or anything. I waited an hour and a half. | 0non-cybersec
| Reddit | 134 | 505 |
[Game tales] Rogue does over 4k damage to miniboss.. I want to preface this by saying none if the following is RAW as we are playing in a very homebrewed campaign.
Recently my players have gone around collecting stones of power, each one attuned to a different element. Use of the stone pulls from a specific pool of points that once used up, cause rapid levels of exhaustion.
My rogue had picked up the fire stone.
The scene itself took place in an underground chapel. A buffed up death tyrant, two celestial sarcophagus, and a literal army of undead were pouring out of the walls and floor below.
It was supposed to be a medium challenge fight, but our main tank was unable to make it, so we now had a party of a bard, a healer, a rogue, and a wizard. Any one of them could potentially be one shot.
Things were taking a turn for the worse when my rogue for reasons unbeknownst to be launched himself into the dead center of the undead mass.
When he asked me how many, I estimated to be about 150 within about 30 feet of him.
Then he said, I used heat drain. Never has my palm hit my head so hard.
I had originally designed this moved keeping in mind that our campaign is often comprised of a few tough bosses, not hundreds of mooks. The ability reads as follows.
"You drain all the heat from every creature around you causing 5d10 cold damage to each one. You may then take the total heat gatherers and channel it into one mighty blow dealing the sum total of damage done to the surrounding creatures."
He rolled 35 damage. Per creature....multipliedby 150.
150.
He then channeled this tiny super nova he gathered directly into the death tyrant, telling the creature in a single blow.
The resulting blast was enough to melt the surrounding sarcophagus and set the remaining undead ablaze, though the party didnt escape without absorbing a little aoe, they definitely got the better end of the deal.
*tldr- rogue uses infinity like power stone to flash freeze a mob of undead and char broil a death tyrant* | 0non-cybersec
| Reddit | 484 | 2,028 |
Block all but specified range of ip's input to an specific port. <p>In a CentOS 7 web server, how do I configure firewalld to block all but a specific list of ip addresses from making successful http or https requests?</p>
<p>I know that I can use <code>httpd.conf</code> to restrict by ip, but how can I get firewalld to restrict by ip? What file? Do I use <code>firewall-cmd</code>? What syntax?</p>
<p>I imagine this involves creating one or more rich rules, which are described in <a href="https://fedoraproject.org/wiki/Features/FirewalldRichLanguage" rel="nofollow">the documentation</a>. But I want to make sure that I do this properly. For example, would one rule specify rejecting all http/s requests from anyone? And then would another rule be required to approve http/s requests for each specific ip? Would the rule be for the service http/s, or would the rule be for the port 443? Or some combination? What about logging the rejections and acceptances?</p>
| 0non-cybersec
| Stackexchange | 263 | 978 |
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 | 349 | 1,234 |
In c/c++, are block-scope variables stacked only if the block is executed?. <p>Suppose this: </p>
<pre><code>void func()
{
...
if( blah )
{
int x;
}
...
}
</code></pre>
<p>Is the space for <code>x</code> reserved on the stack immediately when <code>func</code> is entered, or only if the block is actually executed?<br>
Or is it the compiler's choice?<br>
Do C and C++ behave the same about this? </p>
| 0non-cybersec
| Stackexchange | 142 | 415 |
rpc.statd and avahi-daemon listening on all networks?. <p>Background:<br>
- I'm running a home Debian GNOME desktop connected to the internet through an ethernet cable to an ethernet router.<br>
- I have a printer connected directly to my PC with a USB cable.<br>
- My PC has 2 hard drives.<br>
- I occasionally copy pictures from my camera to my PC using a USB cable.<br></p>
<p>rpc.statd and avahi-daemon are listening on all networks and not only on 127.0.0.1 like cupsd and portmap.</p>
<p>I've read their man pages and various forums but I can't figure out if they are actually really needed. I mean, does GNOME need them ? Is portmap needed ? Is it possible to make them listen to 127.0.0.1 only ?</p>
<pre>
root@debian:/# netstat -nap | grep -v "unix"
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 127.0.0.1:111 0.0.0.0:* LISTEN 168/portmap
tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN 1594/cupsd
tcp 0 0 0.0.0.0:42469 0.0.0.0:* LISTEN 1180/rpc.statd
tcp6 0 0 ::1:631 :::* LISTEN 1594/cupsd
udp 0 0 0.0.0.0:34406 0.0.0.0:* 1180/rpc.statd
udp 0 0 0.0.0.0:5353 0.0.0.0:* 1536/avahi-daemon:
udp 0 0 127.0.0.1:111 0.0.0.0:* 1168/portmap
udp 0 0 0.0.0.0:42397 0.0.0.0:* 1536/avahi-daemon:
udp 0 0 0.0.0.0:932 0.0.0.0:* 1180/rpc.statd
udp 0 0 0.0.0.0:68 0.0.0.0:* 16068/dhclient
udp6 0 0 :::5353 :::* 1536/avahi-daemon:
udp6 0 0 :::59211 :::* 1536/avahi-daemon:
</pre>
| 0non-cybersec
| Stackexchange | 651 | 1,821 |
WINDOWS 10: I receive a "no valid IP configuration" on both WIFI and Ethernet.. <p>More specs:</p>
<ul>
<li>It works on all other devices in my house.</li>
<li>I am missing a connection-specific DNS suffix, and no default gateway. The auto ip is a 169.54.x.x</li>
<li>The ip address of the router : IP Address 169.254.1.4</li>
</ul>
<p>Tried:
-reinstalling drivers
- rebooting everything</p>
<p>Let me know what steps I can take, I will be here for immediate response. </p>
| 0non-cybersec
| Stackexchange | 165 | 487 |
My son hates himself and I feel responsible. My 14 year old son recently come to me bawling and literally shaking, and after nearly an hour of calming him down he told me he *hated* himself and that he wanted to be a girl. I stayed calm and told him that I love him for who he is no matter what and that he should feel free to be and act like who he really is, and he seemed happy with that. But in reality, I was FLIPPING out inside my mind. My head is still in spirals and I've gotten practically no sleep for the past 4 days
I'm accepting of people for whoever they want to be, and it doesn't bother me if my son wants to be a girl. What I'm absolutely terrified about is what this is going to mean for his life now...I'm scared to death. I just want him to be able to live a normal life and not have to deal with something as monumental as this, but even more so I've now got it in my head that I brought this upon him.
When he was around age 3 he started dressing up in his older sister's clothes. No biggie, obviously, kids do stuff like this all the time and I thought it was completely normal. He kept doing this until around the time he went into kindergarten, but I would paint his nails on the weekends and he loved doing that for the next couple of years.
Several years passed and I thought he'd outgrown his girly phase, but around the time he was 9 years old my daughter's clothes started disappearing and we routinely found them in my son's closet. I asked him about it and he refused to answer me, and after that he became really quiet and withdrawn from us as a family.
I've continued to find girl's clothing hidden in his room to this day, but out of fear of sending him into withdrawal again I never confronted him about it a second time.
I feel like I've made so many mistakes as a parent and as a result I've pushed my son into a harder life. For one, I encouraged his girly behaviours and interests growing up and often let him knew I thought it was adorable. Secondly, he's never had any male role-models in his life and I feel ashamed for not giving him that. And finally, I never confronted him again after the first time out of my own fear which might've made things worse and him think what he was doing was shameful. Who bloody knows how much stress I've caused him...
I've never cared about whether my children fit in with their gender roles or not, I couldn't care less about that stuff. But the fact that he said he HATED himself and wanted to be an actual girl completely threw me off. I feel like I did this to him, or at least made it worse, and I'm just really worried about what this means for his life now.
Sorry for being so long, it was actually a lot longer originally but I deleted a bunch of stuff. I have no one to talk to about this, my parents will probably think I'm responsible and tell me everything I did wrong. I just need to rant to someone.
EDIT: I'm overwhelmed by all the comments and private messages I've received, and I really appreciate everyone's help and reassurance here. Sorry I can't reply to everyone, but you guys have all helped and thank you for that. I will 100% be finding a therapist or counselor very soon that's qualified for this to talk things over with and I'm going to try to talk to my son again in depth to try to gauge exactly where he is and what he wants/needs at this point. | 0non-cybersec
| Reddit | 780 | 3,378 |
I'm 15 and I'm killing myself.. I'm 15 years old. I've had Binge Eating Disorder for what, 4 years now? I've been trying to lose weight ever since and it's ruined my life. A few months ago I found out that I had gained so much weight to the point that I got NAFLD (Non alcoholic fatty liver disease). It was only a few minor infiltrations back then. It was easily reversible, I just had to make a few diet changes. You know what I did instead? I gained 25lbs in about 3 months. Every day I would eat upwards of 3,000 calories and would say "Oh it's fine, I'll diet tomorrow". Every. Single. Day. I found out via an ultrasound that my liver was almost completely fatty and it was being damaged. Along with the myriad of other minor health problems I have, I came to the realisation that I'm dying. I'm eating myself to death. I constantly feel heart pains, chest pains and liver pains. You'd think that would be the line, right? Nope. Cue 2 weeks of nonstop binging. 2 weeks of me telling myself everyday "tomorrow will be different." I've been lying to my BED support worker about my weight - she thinks I'm 20lbs lighter than I actually am. Purely because I'm to embarrassed to admit that I've gained that much fat. My BMI is 34. When I first found out that I was developing NAFLD, it was about 29. I need help really bad and I don't think I have the willpower to help myself. | 0non-cybersec
| Reddit | 334 | 1,377 |
I think I'm letting the internet ruin my life. I can't seem to shake the internet. I love it, but it's a curse. I have become so involved with it, it's like my life is only on the internet. I'm only real on the internet. I feel like I forgot how to have friends and be a real person who has wants and dreams and is motivated.
I deserted my old life for the internet, and while it was really fun for a while, now it's all I have, and it's really lonely. When I needed a way out, the internet was the way I went. I met a lot of new friends and made a lot of new connections over the internet, and I keep in touch with many of them, but travel takes money, and I don't have a lot of that right now, so it isn't like I can just go visit them whenever I want. My old friends.. I miss them. I talk to them pretty regularly but, I just left. I left because I couldn't afford to stay, but I just left. I miss them. I miss having people to be around.
To make things worse, I never really managed to build a decent foundation for my life. I'm in my mid twenties, and I live with my parents. I am unemployed (looking for a job for 2 months straight now), I have no degree. I'm working on getting certified to go into basic medicine, like a medical assistant or something. I just never did anything for myself because I honestly don't really know what to do with myself. And that's why I always choose to run, and take the easy way out.. Because I end up coming back to all these problems I put on the backburner. Life's a bitch. Can't run this time, I'm learning.
I just don't like the person I am right now. I'm desperate for change, but, I don't really know where to begin, since I've apparently just avoided dealing with myself this entire time.
So I go on the internet to distract myself by making this post. I am hoping that maybe someone else understands what it's like to get lost in the internet..
O_O | 0non-cybersec
| Reddit | 465 | 1,906 |
Is it possible to get org-mode to show breadcrumbs in agenda todo list?. <p>In Emacs, I have a set of TODOs in the following format</p>
<pre><code>* H1
** H2
*** H3
**** TODO X
</code></pre>
<p>When I look at the agenda-todo view, it shows up only as <code>TODO x</code>. Is there any way to get the agenda view to display it as <code>H1/H2/H3/TODO X</code> ?</p>
| 0non-cybersec
| Stackexchange | 136 | 366 |
$B(n,z)$ "uniformly" converges to $A(n,z)$ which uniformly converges to G(z)?. <p>(1). Suppose that $\{A(n,z)\}_{n=2}^{\infty}$ and G(z) are entire functions. Suppose that for $z\in S(1/2):=\{|\mathrm{Im}(z)|< 1/2\}$ and any $0<\epsilon <1$, there exists a positive integer $N=N(\epsilon)$, such that for any integer $n\geqslant N$, we have $\left|G(z)-A(n,z)\right|<\epsilon$. Thus we say that $\{A(n,z)\}_{n=2}^{\infty}$ uniformly converge to $G(z)$ in the critical strip $S(1/2)$.</p>
<p>(2). Suppose that $\{B(n,z)\}_{n=2}^{\infty}$ are entire functions. Supposed that for $z\in S(1/2)$ and any $0<\epsilon <1$, there exists a positive integer $M=M(\epsilon)$, such that for any integer $n\geqslant M$, we have $\left|A(n,z)-B(n,z)\right|<\epsilon$. </p>
<p><strong><em>Question</em></strong>
Do we still say that $\{B(n,z)\}_{n=2}^{\infty}$ uniformly converge to $A(n,z)$ in the critical strip $S(1/2)$?</p>
<p>If not, what kind of name is used for the convergence described in (2)?</p>
<p>The reason I am not quite sure is because in (1) the uniform convergence target function, $G(z)$, is independent of $n$; while as in (2) the convergence target function, $A(n,z)$, is dependent on $n$, so it is a moving target.</p>
| 0non-cybersec
| Stackexchange | 452 | 1,264 |
How do I retain globals in AppleScript between invocations under Mojave?. <h1>Problem</h1>
<p>Apparently with the security changes made in Mojave and now going forward, I lost the ability to store globals between invocations of my scripts. </p>
<p>All that I want to do is to toggle states of connections based on my location (e.g. work versus home toggles ethernet versus WiFi and other stuff). I want to store the state for the next time so that I can know what the setting had been.</p>
<p>I don't do XCode development (I do however program in other languages such as python). Everything for AppleScript is in ScriptEditor (perhaps soon Script Debugger instead). Finally, I am conversant enough to know how to write the scripts and save them as applications. Anything else that I need to use would hopefully be at a "plug-and-play" level of effort.</p>
<h1>Example Script</h1>
<p>Here is an example of a script that I use to toggle the status between presentations and no presentations. In this, pCurrentMode is no longer being maintained between invocations. Under High Sierra, it ran with no problems. Under Mojave, it does not remember the previous invocation state. I have a few other equivalent scripts that do the same. They are saved as .app files in the Scripts folder (for menu access whenever I need them).</p>
<pre><code>property pAppsToToggleOFF : {"Mail", "Safari"}
property pAppsToToggleinMSB : {"EasyMP Network Projection"}
property pAppsToToggleinTeach : {"AirServer", "Panopto"}
property blueutil : "/usr/local/bin/blueutil"
property pCurrentMode : "Off"
on run {}
-- ask how to set
set whichMode to choose from list {"Teach", "MSB Show", "Off"} with prompt "How?" default items pCurrentMode
if result is false then return
if (whichMode is equal to pCurrentMode) then return
set pCurrentMode to whichMode as text
set inTeachMode to (whichMode as text is equal to "Teach")
set inMSBMode to (whichMode as text is equal to "MSB Show")
set inONMode to (inTeachMode or inMSBMode)
set inOFFMode to (whichMode as text is equal to "Off")
if (inONMode) then
-- start presentation mode
if (inTeachMode) then
repeat with apptoToggle in pAppsToToggleinTeach
try
tell application apptoToggle to activate
end try
end repeat
else if (inMSBMode) then
repeat with apptoToggle in pAppsToToggleinMSB
try
tell application apptoToggle to activate
end try
end repeat
end if
repeat with apptoToggle in pAppsToToggleOFF
try
tell application apptoToggle to quit
end try
end repeat
-- switch to WiFi and turn off bluetooth
do shell script "scselect WiFi"
do shell script blueutil & " off"
else if (inOFFMode) then
-- end presentation modes
repeat with apptoToggle in pAppsToToggleinTeach
try
tell application apptoToggle to quit
end try
end repeat
repeat with apptoToggle in pAppsToToggleinMSB
try
tell application apptoToggle to quit
end try
end repeat
-- switch to ethernet and turn on bluetooth
do shell script "scselect Ethernet"
do shell script blueutil & " on"
end if
-- show or hide the dock and desktop icons
hidetheDock(inONMode)
showDesktopIcons(not inONMode)
end run
on showDesktopIcons(state)
set theCmd to "defaults write com.apple.finder CreateDesktop " & state & "&& killall Finder"
do shell script theCmd
end showDesktopIcons
on hidetheDock(state)
tell application "System Events" to set the autohide of dock preferences to state
end hidetheDock
</code></pre>
<h1>A Concluding General Question</h1>
<p>By way of reference, when I started looking for insights on how to solve this problem, as a beginner/intermediate user of AppleScript, I was lost about where I should go for the most recent information to figure out why this was now happening. This prompts me to ask a follow up based on a question from two years ago posted at this link.</p>
<p><a href="https://apple.stackexchange.com/questions/281092/applescript-alternatives">AppleScript alternatives</a></p>
<p>In a nutshell, where do programmers go to find resources about the <strong>newest</strong> practices to write robust scripts with AppleScript?</p>
<p>I stumbled across the site for Script Debugger while subsequently looking for "applescript globals". The site offered some insights. I would be hard pressed to read all of the forum posts to cull the information that I need laid out in a tutorial + example manner. But if this is the <strong>current</strong> practice, so be it.</p>
| 0non-cybersec
| Stackexchange | 1,264 | 4,703 |
Show that if $f$ is injective, then $f^{-1}(f(C))=C$. <p>Once again I am stuck on a question from Lay's Introduction to Analysis with Proof:</p>
<blockquote>
<p>Suppose that $f : A \rightarrow B$ and let C $\subseteq$ A and $D \subseteq B$. Show that if $f$ is injective, then $f^{-1}(f(C))=C$</p>
</blockquote>
<p>I just need to show that $f^{-1}(f(C) \subseteq C$ and $C \subseteq f^{-1}(f(C))$.</p>
<p>I have started with this but am unsure of where to go next;</p>
<p>Let $x \in f^{-1}(f(C))$. Then, $x \in \{f^{-1}(a) \mid a \in f(C)\}$. </p>
| 0non-cybersec
| Stackexchange | 216 | 555 |
Biblatex cite with footnote only once, with use of brackets. <p>I've started putting into practice the answer to <a href="https://tex.stackexchange.com/questions/20637/biblatex-which-style-for-a-footnote-once-then-nothing/20741#20741">this question</a>. Yet I would like to change this so that there are brackets around the citations:</p>
<ul>
<li>in the superscript in text, </li>
<li>in the superscript in footnote, </li>
<li>in the bibliography.</li>
</ul>
<p>I've managed to get the first one and the last one working. The second one however, I don't know how to do this. </p>
<p>Note that I mainly write in english and in dutch, so I don't think there is much babel interference.</p>
<p>Also, would there be a way to order the footnotes so that first all ''normal'' <code>\footnote{}</code> are printed and below that all <code>\sfcite{}</code> citational footnotes (per page that is)?</p>
<p>Here's what I've managed to concoct:</p>
<pre><code>\documentclass{article}
\usepackage[english]{babel}
\usepackage[pdfborder={0 0 0}]{hyperref}
\usepackage[citestyle=numeric-comp,sorting=none,hyperref]{biblatex}
\usepackage{filecontents}
% No brackets around the number of each bibliography entry
\DeclareFieldFormat{labelnumberwidth}{\textbf{[#1]}}
%---------------------------------------------------------------
% Essentially verbatim from Joseph Wright
% http://www.texdev.net/2010/03/08/biblatex-numbered-citations-as-footnotes/
\makeatletter
\ExecuteBibliographyOptions{citetracker,sorting=none}
\DeclareCiteCommand{\notefullcite}[\mkbibbrackets]
{\usebibmacro{cite:init}%
\usebibmacro{prenote}}
{\usebibmacro{citeindex}%
\usebibmacro{notefullcite}%
\usebibmacro{cite:comp}}
{}
{\usebibmacro{cite:dump}%
\usebibmacro{postnote}}
\newbibmacro*{notefullcite}{%
\ifciteseen
{}
{\footnotetext[\thefield{labelnumber}]{%
\usedriver{}{\thefield{entrytype}}\addperiod}}}
\DeclareCiteCommand{\sfcite}[\cbx@superscript]%
{\usebibmacro{cite:init}%
\let\multicitedelim=\supercitedelim
\iffieldundef{prenote}
{}
{\BibliographyWarning{Ignoring prenote argument}}%
\iffieldundef{postnote}
{}
{\BibliographyWarning{Ignoring postnote argument}}}
{\usebibmacro{citeindex}%
\usebibmacro{sfcite}%
\usebibmacro{cite:comp}}
{}
{\usebibmacro{cite:dump}}
\newbibmacro*{sfcite}{%
\ifciteseen
{}
{\xappto\cbx@citehook{%
\noexpand\footnotetext[\thefield{labelnumber}]{%
\fullcite{\thefield{entrykey}}\addperiod}}}}
\newrobustcmd{\cbx@superscript}[1]{%
\mkbibsuperscript{[#1]}%
\cbx@citehook
\global\let\cbx@citehook=\empty}
\let\cbx@citehook=\empty
\makeatother
%---------------------------------------------------------------
\begin{filecontents}{\jobname.bib}
@article{ref1,
hyphenation = {american},
title = {Natural Products as Sources of New Drugs over the Last 25 Years},
author = {Newman, D.J. and Cragg, G.M.},
journal = {J. of Nat. Prod.},
volume = {70},
number = {3},
pages = {461--477},
year = {2007}}
@article{ref2,
hyphenation = {american},
title = {Natural products as leads to potential drugs: an old process or the new hope for drug discovery?},
author = {Newman, D.J.},
journal = {J. of Med. Chem.},
volume = {51},
number = {9},
pages = {2589--2599},
year = {2008}}
@online{ref3,
author = {Quintin, C.},
title = {Les eponges},
url = {http://christophe.quintin.pagesperso-orange.fr/Liste_Doc.html},
urldate = {2009-05-03}
}
\end{filecontents}
\addbibresource{\jobname.bib}
\begin{document}
First citation.\sfcite{ref1,ref2} Some text\footnote{A footnote}.
\pagebreak
Second citation\sfcite{ref1}, second citation\sfcite{ref2}, first citation.\sfcite{ref3}
\printbibliography
\end{document}
</code></pre>
| 0non-cybersec
| Stackexchange | 1,287 | 3,918 |
How to deal with a bad/ unfair DM?. Let's ignore the (No DnD>DnD). I have tried talking to him after almost every session, and he doesn't listen. He's also the only source for DnD in the area.
1). He changes DM calls between sessions, without telling anyone, until they try to do something that he previously said yes to. Then he tells them they can't do it.
2). He'll make certain ability checks fail for some characters, but make others succeed.
3). I can't use investigation (which he said was used to put together various clues) to try and figure out what these clues mean, effectively creating an unsolvable puzzle.
4). Companions that get their own initiative rolls, just go after their owner/controller's turn, effectively limiting certain strategies.
5). Certain characters get useful items when they scavenge, but other characters don't.
*(Such as when I search a boss and find absolutely nothing, but another person searches some rotting corpse and finds a +1 longsword)*
These are just a few examples, and I know I'm complaining, but this is my only way to play DnD. | 0non-cybersec
| Reddit | 261 | 1,086 |
DRM on CSS or even HTML files through domain locking via Javascript?. <p>If you are planning to downvote me to oblivion, let me clarify what this question is about:</p>
<ol>
<li>I am not interested to prevent someone from copying my website. I know there are no foolproof method.</li>
<li>My goal here is to merely make it more difficult for <strong>non-technical</strong> users who are ripping my site via right-click save-as on their browser.</li>
</ol>
<p>I have tried out JSCrambler and it seems like their ability to <strong>obfuscate javascript files</strong> are pretty good. They even have <strong>domain locking</strong> which renders an obfuscated js file useless on a domain not specified at the time of compilation. The technology is pretty solid.</p>
<p>So that brings up another question:</p>
<h2>Will it be possible to protect your CSS?</h2>
<p>I thought about creating a <code><style></code> element via javascript and appending it to the document. On Chrome, saving this as a complete page will result in a page with the said <code><style></code> element included in the html itself.</p>
<p>This is where I am out of ideas. Is it possible to have a way of styling your elements through javascript that will not be saved by the browser?</p>
<p><strong>EDIT</strong></p>
<p>Let me clarify what the <strong>exact</strong> use case is:</p>
<p>I run an affiliate marketing website specializing in advertising for Amazon products. There is someone on the internet, Joe, who is visiting my site and right click saving it to run as his own. Joe <strong>does not know</strong> CSS or Javascript, and he is lazy. He is not willing to spend more than a few minutes trying to figure out how to rip my website - this means that he will not bother to screenshot it and reconstruct it from scratch as it is too troublesome for him. Disabling right click save-as doesn't work anymore as a simple google search will reveal a solution available on the menu.</p>
<p>All I need is enough disincentive to discourage Joe from ripping my site. There are other affiliate websites he can rip. He is not interested to spend a long time trying to rip <strong>mine</strong> if there are alternative available. If Joe has to learn CURL from a command line to download my page, it is probably enough incentive to discourage him.</p>
<p>Right now, my affiliate website utilizes no javascript as it's purely html and css.</p>
| 1cybersec
| Stackexchange | 607 | 2,423 |
Some keyboard keys in Lenovo Ideapad 320E-15IKB D not working after Ubuntu 18.04.1 LTS installation. <ul>
<li>Laptop: Lenovo Ideapad 320E-15IKB D,</li>
<li>Memory: 8 GB,</li>
<li>Processor: Intel® Core™ i5-7200U CPU @ 2.50GHz × 4,</li>
<li>Graphics: Intel® HD Graphics 620 (Kaby Lake GT2),</li>
<li>OS Type: 64-bit,</li>
<li>HDD: 1 TB.</li>
</ul>
<p>I bought this laptop with pre-installed Windows 10. Now I have installed only
one OS, Ubuntu 18.04.1 LTS. Everything is going smooth but some keys like "Q", "P", "Tab", "Backspace" etc are not working at all, whereas the onscreen keyboard is working fine.</p>
<p>I have tried enough by changing keyboard layout and many other ways as described on internet to get the solutions, but no result. Region & Language in the system are currently set as follows,</p>
<ul>
<li>Language: English (United States),</li>
<li>Formats: United States,</li>
<li>Input Sources: English (US).</li>
</ul>
<p>How can I fix debug this issue?</p>
| 0non-cybersec
| Stackexchange | 335 | 982 |
Not enough storage for El Capitan; no way to free up space. <p>I wanted to upgrade my Macbook 2008 from Yosemite to El Capitan. Unfortunately, when I downloaded it and restarted my computer, on the "select the disk on which to install" page the only location, Macintosh HD, didn't have enough space (by about 2 GB). It doesn't seem like there's a way to free up space from this startup menu, though. I can open Disk Utility from this menu, and it seems logical to put some method of freeing up disk space from there, but if there is, I can't find it.</p>
<p>Is there a way to get out of this startup menu so I can free up space, or a way to free up space directly from the menu? This is pretty frustrating because it seems like a major design flaw if it tells you you don't have enough storage for a certain thing, but it doesn't let you free up the storage to download the thing.</p>
<p>There's already a question exactly like mine: <a href="https://apple.stackexchange.com/questions/233300/stuck-in-update-boot-not-enough-disk-space">Stuck in update boot (not enough disk space)</a>
But no one has answered it, so I think it's okay to ask it again.</p>
<p>EDIT: I can also access Terminal which I could potentially also use</p>
<p>EDIT AGAIN: Nevermind, it looks like Macintosh HD is read-only while I'm in this boot menu. At least terminal says "read-only file system" when I try to use rmdir on something.</p>
| 0non-cybersec
| Stackexchange | 389 | 1,423 |
Reducing space between table rows. \arrayrowstretch and \extrarowheight not working. <p>How do I decrease the space between the rows in the table shown? I was unable to do so using <code>\arrayrowstretch</code> and <code>\extrarowheight</code>. Here is the code I used:</p>
<pre><code>\newcommand*{\cvpressentry}[4]{
{\setlength\tabcolsep{1ex}}
{\setlength{\extrarowheight}{0pt}}
\def\arraystretch{0.7}
\begin{tabular*}{\textwidth}{@{\extracolsep{\fill}}L{1.5cm} L{14.5cm}}
\publdatestyle{#1} & \publpubtitlestyle{#2} \publauthorstyle{#3} \publvenuestyle{\href{#4}{\faExternalLink}}
\end{tabular*}
</code></pre>
<p><a href="https://i.stack.imgur.com/cpb2Y.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/cpb2Y.png" alt="table with row borders showing the space between the rows"></a></p>
<p>The table <code>\hline</code>s are added for clarity of the issue.</p>
<p>UPDATE: Based on the Sveinung's observation of separate tabular environments, I removed it and made it into a single tabular environment and it solved the problem.</p>
| 0non-cybersec
| Stackexchange | 368 | 1,086 |
How to replace certain data frame value with it's unknown column name?. <p>I have a large data frame with unknown column names and numeric values 1, 2, 3, or 4.
Now I want to replace all 4 values with it's column name and all 1, 2 and 3's with an empty value. </p>
<p>Ofcourse I can make a loop of some kind, like this:</p>
<pre><code>df <- data.frame(id=1:8,unknownvarname1=c(1:4,1:4),unknownvarname2=c(4:1,4:1))
for (i in 2:length(df)){
df[,i] <- as.character(df[,i])
df[,i] <- mgsub::mgsub(df[,i],c(1,2,3,4),c("","","",names(df)[i]))
}
</code></pre>
<p>This would be the result:</p>
<pre><code> id unknownvarname1 unknownvarname2
1 1 unknownvarname2
2 2
3 3
4 4 unknownvarname1
5 5 unknownvarname2
6 6
7 7
8 8 unknownvarname1 unknownvarname2
</code></pre>
<p>For a data frame this size that's no problem at all. But when I try this loop on large data frames with up to 30k and up to 40 uknown variables, the loop takes ages to complete.</p>
<p>Does anyone know of a faster way to do this? I tried functions like <code>mutate()</code> of <code>dplyr package</code> but I could not manage to make it work.</p>
<p>Many thanks in advance!</p>
| 0non-cybersec
| Stackexchange | 440 | 1,353 |
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 | 349 | 1,234 |
how to refresh facebook access token for server side (in facebook-php SDK)?. <p>I'm using the Facebook PHP SDK to call relevant APIs to post and get data. At present I'm saving a user access token in the database but it expires after 60 days. How can I refresh a user access token? </p>
<p>1 . When do I need to refresh the access tokens? After it expires, or before?</p>
<p>2 . What is the best way to refresh access tokens?</p>
<p>3 . Should my users need to login again to refresh access token? </p>
<p>This is the function that I'm using to extend the access token. but expire time remain same.</p>
<pre class="lang-php prettyprint-override"><code>public function getExtendedAccessToken($access_token)
{
$token_url="https://graph.facebook.com/oauth/access_token";
$params=array('client_id'=>self :: appId,'client_secret'=>self :: appSecretId,'grant_type'=>'fb_exchange_token','fb_exchange_token'=>$access_token);
$response = $this->curl($token_url,$params);
$response = explode ('=',$response);
$response = explode ('&',$response[1]);
$response = $response[0];
return $response;
}
</code></pre>
| 0non-cybersec
| Stackexchange | 354 | 1,232 |
SQL alwayson manual Failover Cluster failed because a duplicate IP address detected. <p>When I manually tried to make a failover I got the following errors: "SQL always on Cluster IP address resource listener cannot be brought online because a duplicate IP address was detected on the network. Please ensure all IP addresses are unique. event 1049"</p>
<p>As a result, all the resources of the Cluster\Listener\witness were in a failure state and could not be moved back to online state.</p>
<p>When I aborted the failover attempts Everything returned to normal.</p>
<p>version: SQL SERVER 2016 SP2 Enterprise edition 2 nodes (Primary and secondary)</p>
<p>appreciated to receive your response and suggestions</p>
<p>Thanks and Regards</p>
<p>Erez Hasman</p>
| 0non-cybersec
| Stackexchange | 196 | 765 |
QML : how to pass javascript function as argument in another function. <p>I have QML code, for example this code</p>
<pre><code>Item {
id:self;
function update(){
var visitFunc = self.applyUpdate;
innerTraversal(self,visitFunc);
}
function reset(){
var visitFunc = self.applyReset;
innerTraversal(self,visitFunc);
}
function innerTraversal(obj, visitFun){
console.log(typeof visitFun);
if(obj!== self && visitFun && typeof visitFun ==="function")
visitFun(obj);
if(hasChilderns(obj)){
var objChilderns = obj.children;
for(var i=0 ; i< objChilderns.length ; i++){
innerTraversal(objChilderns[i]);
}
}
}
function hasChilderns(obj){
if(typeof obj.children !== 'undefined')
return true;
else
return false;
}
function applyReset(obj){
if(typeof obj.reset === 'function')
obj.reset();
}
function applyUpdate(obj){
if(typeof obj.update === 'function')
obj.update();
}
}
</code></pre>
<p>in normal javascript this works cool, but when I use this code in QML the bad thing is visitFun always has type of undefined, and it does not work..</p>
<p>any idea how to make this work ? </p>
| 0non-cybersec
| Stackexchange | 393 | 1,366 |
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 | 349 | 1,234 |
Tools to modify UEFI Variables in Windows/Linux?. <p>I have a DELL machine that use Phoenix SecureCore Tiano as its UEFI/BIOS
However, it is totally not configurable as its UEFI shell & menus are hidden in BIOS Setup.</p>
<p>I'm wondering if there were tools that can modify the UEFI settings(such as Boot Items)
in user mode?
such as "efibootmgr" in linux.</p>
<p>btw, because it is not configurable, I think the boot process is in legacy mode
so that's to say OSes can not detect the UEFI exist, am i right?</p>
<p>so, that's the paradox:
I must be boot in non-legacy mode to enable UEFI tools to modify boot items in user mode?
but I must enable UEFI tools to modify boot items first to enable non-legacy boot?</p>
| 0non-cybersec
| Stackexchange | 218 | 727 |
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 | 349 | 1,234 |
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 | 349 | 1,234 |
Finding the smallest field containing multivariate polynomial evaluations of the roots of an irreducible polynomial. <p>$\newcommand\Q{\mathbb Q}$Suppose I have an irreducible polynomial $f\in\Q[x]$ and suppose I know the roots say $r_1,\dots,r_n\in \bar \Q$. I want to know if there is an easy way to "compute" the smallest number field $K$ such that we have
$$a_0(r_1,\dots, r_n) + a_1(r_1,\dots, r_n)x + \dots + a_k(r_1,\dots, r_n)x^k \in K[x]$$
where $a_0,\dots, a_k \in \Q[x_1,\dots, x_n]$. I am actually only interested in knowing $[K:\Q]$.</p>
<p>I suppose this is "strongly" dependent on how $a_0,\dots, a_k$ are constructed. In my particular case, I want to prove that $[K:\Q]$ is actually always even. I guess I can go into details of the $a_i's$ but I am not sure if this will help in solving $[K:\Q]$. For me, the multivariate polynomials $a_0,\dots,a_k$ are not symmetric but they are certainly not random (i.e. there are non-trivial permutations of the $n$-indeterminates that preserve the $a_i$'s). I do not know if any of these information helps. </p>
<p>Even a specific example that could give me a start on how to solve this kind of problem is very much appreciated.</p>
| 0non-cybersec
| Stackexchange | 377 | 1,192 |
Atiyah's vector bundles over an elliptic curve. <p>I'm reading through Atiyah's paper that classifies vector bundles over an elliptic curve, and I'm a little confused about one of his proofs. </p>
<p>Lemma 15(i) states that if $E \in \mathcal{E}(r,d)$ is a vector bundle of rank $r$ and degree $d\geq0$ over $X,$ then $s:=h^0(X,E)=d$ if $d>0$ and $s=0$ or $1$ if $d=0.$ </p>
<p>For the proof, if $d\geq r,$ choose a maximal splitting $E=(L_1 ,...,L_r)$ with each $L_i>1$ (where 1 denotes the trivial line bundle). But in Lemma 11 he has the equation </p>
<p>$d=deg(E)=\sum^{r}_{1} deg(L_i).$ If each $L_i>1$ doesn't that mean $deg(L_i )\geq2$ so $deg(E)\geq2r?$ But we are only assuming $d\geq r.$</p>
<p>Anyways, If $deg(L_i)\geq 2 $ then it's clear that $H^1 (X,L_i)=0$. Is that how he claimed that $H^1 (X,L_i)=0$ in the next line or is he using something else?</p>
<p>EDIT: Actually, we don't necessarily have $deg(L_i)\geq 2$ since $1$ denotes the trivial line bundle which has degree $0$. So if $L_i >1$ it just means that $deg(L_i)>0.$ Still, how do we know that $L_i >1$? And how does this imply $H^1 (X,L_i)=0$?</p>
<p>We say that $L_1 \geq L_2$ if $\Gamma Hom(L_2 ,L_1)\neq 0.$ It implies that $deg(L_1)\geq deg(L_2).$ </p>
<p>$\Gamma Hom(L_2,L_1) $ is the space of global sections of the bundle $Hom(L_2,L_1)≅L^*_2 \otimes L_1$</p>
| 0non-cybersec
| Stackexchange | 559 | 1,373 |
I'm not able to connect to my wifi. <p>I'm using ubuntu 12.04, and I'm having some issues in connecting to my home's wifi. Here's the quick resume:</p>
<ol>
<li>my home wifi works, because I'm surfing trhough ethernet</li>
<li>my wireless drivers work, because I can successfully connect to my office's wifi</li>
<li>I'm not even able to ping my router!</li>
</ol>
<p>So, I cannot understand the reason for it to not work! I'm using ubuntu 12.04. Here are informations about the connection and similar:</p>
<pre><code>alecive@calliope:~$ nm-tool
NetworkManager Tool
State: connected (global)
- Device: eth0 -----------------------------------------------------------------
Type: Wired
Driver: atl1c
State: unavailable
Default: no
HW Address: 00:24:BE:EB:DA:87
Capabilities:
Carrier Detect: yes
Speed: 100 Mb/s
Wired Properties
Carrier: off
- Device: wlan0 [InfostradaWiFi-004309] ---------------------------------------
Type: 802.11 WiFi
Driver: iwlwifi
State: connected
Default: yes
HW Address: 00:27:10:2B:68:28
Capabilities:
Speed: 135 Mb/s
Wireless Properties
WEP Encryption: yes
WPA Encryption: yes
WPA2 Encryption: yes
Wireless Access Points (* = current AP)
FASTWEB-1-00219631C110: Infra, 00:21:96:31:C1:18, Freq 2462 MHz, Rate 54 Mb/s, Strength 82 WPA
Vodafone-23070663: Infra, 00:24:89:94:F6:AE, Freq 2437 MHz, Rate 54 Mb/s, Strength 50 WPA2
belkin.0bc: Infra, 08:86:3B:57:20:BC, Freq 2412 MHz, Rate 54 Mb/s, Strength 44 WPA WPA2
Ivica: Infra, 00:11:50:36:9C:EB, Freq 2412 MHz, Rate 54 Mb/s, Strength 27 WPA
Paola WiFi: Infra, F8:D1:11:62:8C:CF, Freq 2462 MHz, Rate 54 Mb/s, Strength 20 WPA WPA2
FASTWEB-1-0021964482E4: Infra, 00:21:96:44:82:EC, Freq 2462 MHz, Rate 54 Mb/s, Strength 20 WPA
ciao wireless: Infra, 00:25:9C:88:68:56, Freq 2462 MHz, Rate 54 Mb/s, Strength 27 WEP
TISCALI: Infra, 00:24:17:D9:2A:B7, Freq 2462 MHz, Rate 54 Mb/s, Strength 27
*InfostradaWiFi-004309: Infra, AC:E2:15:4A:35:74, Freq 2427 MHz, Rate 54 Mb/s, Strength 90 WPA
LEPRE35: Infra, 58:98:35:7E:D6:9B, Freq 2412 MHz, Rate 54 Mb/s, Strength 24 WPA WPA2
TP-LINK: Infra, 00:14:78:EC:40:AA, Freq 2437 MHz, Rate 54 Mb/s, Strength 24 WPA WPA2
Alice-92034414: Infra, 00:19:3E:15:82:B0, Freq 2437 MHz, Rate 54 Mb/s, Strength 22 WPA
MAMADOU: Infra, F0:7D:68:11:3F:E7, Freq 2437 MHz, Rate 11 Mb/s, Strength 24 WPA WPA2
M&A: Infra, 00:17:F2:E4:83:67, Freq 2412 MHz, Rate 54 Mb/s, Strength 29 WEP
Vodafone-26148616: Infra, 00:24:89:82:19:EE, Freq 2412 MHz, Rate 54 Mb/s, Strength 22 WPA2
FASTWEB-1-001CA2AE2E70: Infra, 00:1C:A2:AE:2E:70, Freq 2437 MHz, Rate 54 Mb/s, Strength 20 WPA
IPv4 Settings:
Address: 192.168.1.8
Prefix: 24 (255.255.255.0)
Gateway: 192.168.1.1
DNS: 8.8.8.8
DNS: 8.8.4.4
alecive@calliope:~$ ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue state UNKNOWN
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eth0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc pfifo_fast state DOWN qlen 1000
link/ether 00:24:be:eb:da:87 brd ff:ff:ff:ff:ff:ff
3: wlan0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP qlen 1000
link/ether 00:27:10:2b:68:28 brd ff:ff:ff:ff:ff:ff
inet 192.168.1.8/24 brd 192.168.1.255 scope global wlan0
inet6 fe80::227:10ff:fe2b:6828/64 scope link
valid_lft forever preferred_lft forever
alecive@calliope:~$ ping 192.168.1.1
PING 192.168.1.1 (192.168.1.1) 56(84) bytes of data.
^C
--- 192.168.1.1 ping statistics ---
13 packets transmitted, 0 received, 100% packet loss, time 12094ms
alecive@calliope:~$
</code></pre>
<p>Can someone please help me? Thanks!</p>
| 0non-cybersec
| Stackexchange | 1,621 | 4,096 |
iOS Image Orientation has Strange Behavior. <p>For the past few weeks I've been working with images in objective-c and noticing a lot of strange behavior. First, like many other people, I've been having this problem where images taken with the camera (or taken with somebody else's camera and MMS'd to me) are rotated 90 degrees. I wasn't sure why in the world this was happening (hence <a href="https://stackoverflow.com/questions/10307521/ios-png-image-rotated-90-degrees" title="my question">my question</a>) but I was able to come up with a cheap work around. </p>
<p>My question this time is <strong>why is this happening</strong>? Why is Apple rotating images? When I take a photo with my camera right-side up, unless I perform my code mentioned above, when I save the photo it gets saved rotated. Now, my workaround was okay up until a few days ago. </p>
<p>My application modifies individual pixels of an image, specifically the alpha channel of a PNG (so any JPEG conversion gets thrown out of the window for my scenario). A few days ago I noticed that even though the image is displayed properly in my app thanks to my workaround code, when my algorithm modifies the individual pixels of the image, it thinks the image is rotated. So instead of modifying the pixels at the top of the image, it modifies the pixels on the side of the image (because it thinks it should be rotated)! I can't figure out how to rotate the image in memory - ideally I would prefer to just wipe away that <code>imageOrientation</code> flag all together.</p>
<p>Here's something else that has been baffling me as well... When I take the photo, the <code>imageOrientation</code> is set to 3. My workaround code is smart enough to realize this and flip it so the user never notices. Additionally, my code to save the image to the library realizes this, flips it, <em>then</em> saves it so it appears in the camera roll properly. </p>
<p>That code looks like so:</p>
<pre><code>NSData* pngdata = UIImagePNGRepresentation (self.workingImage); //PNG wrap
UIImage* img = [self rotateImageAppropriately:[UIImage imageWithData:pngdata]];
UIImageWriteToSavedPhotosAlbum(img, nil, nil, nil);
</code></pre>
<p>When I load this newly saved image into my app, the <code>imageOrientation</code> is 0 - exactly what I want to see, and my rotation workaround doesn't even need to run (note: when loading images from the internet as opposed to images taken with a camera, the <code>imageOrientation</code> is always 0, resulting in perfect behavior). For some reason, my save code seems to wipe away this <code>imageOrientation</code> flag. I was hoping to just steal that code and use it to wipe away my imageOrientation as soon as the user takes a photo and has it added to the app, but it doesn't seem to work. Does <code>UIImageWriteToSavedPhotosAlbum</code> do something special with <code>imageOrientation</code>?</p>
<p>Would the best fix for this problem be to just blow away <code>imageOrientation</code> as soon as the user is done taking an image. I assume Apple has the rotation behavior done for a reason, right? A few people suggested that this is an Apple defect. </p>
<p>(... if you're not lost yet... Note2: When I take a horizontal photo, everything seems to work perfectly, just like photos taken from the internet)</p>
<p>EDIT:</p>
<p>Here are what some of the images and scenarios actually look like. Based off the comments so far, it looks like this strange behavior is more than just an iPhone behavior, which I think is good.</p>
<p>This is a picture of the photo I took with my phone (note the proper orientation), it appears exactly as it did on my phone when I snapped the photo:</p>
<p><img src="https://i.stack.imgur.com/tG0Uf.png" alt="Actual Photo taken on iPhone"></p>
<p>Here is what the image looks like in Gmail after I emailed it to myself (looks like Gmail handles it properly):</p>
<p><img src="https://i.stack.imgur.com/pgIBL.png" alt="Photo as it appears in Gmail"></p>
<p>Here is what the image looks like as a thumbnail in windows (doesn't look like it is handled properly):</p>
<p><img src="https://i.stack.imgur.com/S4rsI.png" alt="Windows Thumbnail"></p>
<p>And here is what the actual image looks like when opened with Windows Photo Viewer (still not handled properly):</p>
<p><img src="https://i.stack.imgur.com/SZKqC.png" alt="Windows Photo Viewer Version"></p>
<p>After all of the comments on this question, here's what I'm thinking... The iPhone takes an image, and says "to display this properly, it needs to be rotated 90 degrees". This information would be in the EXIF data. (Why it needs to be rotated 90 degrees, rather than defaulting to straight vertical, I don't know). From here, Gmail is smart enough to read and analyze that EXIF data, and properly display it. Windows however, is not smart enough to read the EXIF data, and therefore displays the image <strong>improperly</strong>. Are my assumptions correct?</p>
| 0non-cybersec
| Stackexchange | 1,329 | 4,995 |
update values based on values from another table. <p>I have a table (Table A) in DB2 where a columns needs to be updated based on values from values from Table B.</p>
<p>e.g. </p>
<p><strong>Table A</strong> has two columns and following data.</p>
<pre><code> ID LOGIN
01 DONALD.TRUMP
02 BARACK.OBAMA
03 ABRAHAM.LINCOLN
</code></pre>
<p><strong>Table B</strong> has the following data.</p>
<pre><code> ID OLDLOGIN NEWLOGIN
01 DONALD.TRUMP DONALD.T
02 ABRAHAM.LINCOLN ABRAHAM.LIN
</code></pre>
<p>I want to update Table A's LOGIN value, give them the NEWLOGIN values if they exist in OLDLOGIN in Table B.</p>
<p>So the final result in Table A should be like below</p>
<pre><code> ID LOGIN
01 DONALD.T
02 BARACK.OBAMA
03 ABRAHAM.LIN
</code></pre>
<p>What would be the easiest way to do that?</p>
| 0non-cybersec
| Stackexchange | 313 | 866 |
A curious near concurrence. <p>In a triangle $ABC$ with incircle $\omega$, excenters $I_A, I_B, I_C$, let $t_{AB}$ and $t_{AC}$ be the tangent lines to $\omega$ through $I_A$ that are closer to $B$ and $C$ respectively. Construct similarly $t_{BA}$, $t_{BC}$, $t_{CA}$, $t_{CB}$.</p>
<p>Define $D:=t_{BA} \cap t_{CA}$, $E:=t_{CB} \cap t_{AB}$, $F:=t_{AC} \cap t_{BC}$.</p>
<p>My question is:</p>
<ul>
<li><p>is there a way to prove that lines $AD$, $BE$, $CF$ do NOT concur? I am particularly interested in a synthetic method that does not involve writing everything in trilinear coordinates and doing all the calculations.</p></li>
<li><p>is there a reason why, even though they do not concur, they seem to be very close (with respect to the size of $ABC$), which may come as a surprise given the "natural" construction we performed? Why this almost concurrence?</p></li>
</ul>
| 0non-cybersec
| Stackexchange | 289 | 882 |
backup raid content from disks extracted from a NAS. <p>I've a friend with a NAS stuck in the firmware upgrade process, it is Linux based and I believe it use software raid-5 on 4 disks using <code>mdadm</code> <code>/dev/md*</code>.</p>
<p>The product customers support just told how to re-install the factory firmware but all the data will be lost.</p>
<p>The friend have contacted a professional recovery service but they're asking for some money (not cheap).</p>
<p>I'm quite confident with Linux (used to write firmware for embedded devices in the past) but not really with raid.</p>
<p>I'd like to attach the disks to a Debian pc and mount the raid as read-only,
if I understand correctly there are good chances the raid and its configuration will be automatically detected by the kernel (or using <code>mdadm</code>), but how to be sure that no data is written to the disks and what are the steps to mount the raid <code>ro</code>?</p>
| 0non-cybersec
| Stackexchange | 247 | 948 |
Why use IntrospectionFragmentMatcher?. <p>Is there any reason to use <code>IntrospectionFragmentMatcher</code> to determine concrete types of values returned from interface and union fields? </p>
<p>I'm talking about <code>apollo-client</code>. I'm using <code>InMemoryCache</code> with <code>addTypename: true</code>, so the type is known the moment the client gets the response. </p>
<p>Meanwhile my console is plagued with warnings like these: <a href="https://i.stack.imgur.com/GPrlY.png" rel="noreferrer"><img src="https://i.stack.imgur.com/GPrlY.png" alt="console warnings"></a></p>
<p>The only reason I see the documentation hint at is response validation. But why validate the server-sent response at all? If the server is not worth trusting, validation is useless anyway.</p>
| 0non-cybersec
| Stackexchange | 221 | 788 |
how to label rows and columns of matrix?. <p>i have a matrix as follows:</p>
<pre><code>\begin{document}
\[
\begin{bmatrix}
& S1 & S2 & S3 & S4 \\
W1 & 0 & 0 & 0 & 0 \\ % inserting body of the table
W2 & 0 & 0 & 0 & 0
\end{bmatrix}
\]
\end{document}
</code></pre>
<p>i want to write labels S1,S2,S3,S4 and W1,W2 outside the brackets instead of inside, any help would be appreciated.</p>
| 0non-cybersec
| Stackexchange | 174 | 442 |
How to set page title with AngularJS. <p>I am using the following code to display page titles for each of my AngularJS app template, but whenever I try to enter an invalid URL to test the .otherwise I get the following error:</p>
<pre><code>TypeError: Cannot read property 'title' of undefined
at http://localhost/app/js/app.js:34:43
</code></pre>
<p>Below is the app.js, index.html code used:</p>
<pre><code>app.js:
var myApp = angular.module('myApp', ['ngRoute', 'ngSanitize']);
myApp.config(['$routeProvider', function($routeProvider) {
$routeProvider.when('/home',
{ templateUrl: 'templates/index.html',
controller: 'MainController',
title: 'Welcome to Home Page'
});
$routeProvider.otherwise({
redirectTo: '/home'
});
}]);
myApp.run(['$location', '$rootScope', function($location, $rootScope) {
$rootScope.$on('$routeChangeSuccess', function (event, current, previous) {
$rootScope.title = current.$$route.title;
});
}]);
</code></pre>
<p>Index.html:</p>
<pre><code><title ng-bind="title +' - MyAPP Home'"> - MyApp</title>
</code></pre>
<p>Please suggest</p>
| 0non-cybersec
| Stackexchange | 371 | 1,274 |
Returning a value in constructor function of a class. <p>So far I have a <code>PHP</code> class with the constructor</p>
<pre><code>public function __construct ($identifier = NULL)
{
// Return me.
if ( $identifier != NULL )
{
$this->emailAddress = $identifier;
if ($this->loadUser() )
return $this;
else
{
// registered user requested , but not found !
return false;
}
}
</code></pre>
<p>the functionality of <code>loadUser</code> is to look up the database for a particular email address.
When i set the identifier to some email that i'm sure it's not in the database; the first IF is get passed, and goes to the first ELSE. here the constructor should return FALSE; but instead, it returns an object of the class with all NULL values ! </p>
<p>how do i prevent this? thanks </p>
<p>EDIT:</p>
<p>thank you all for the answers. that was quite fast ! I see that the OOP way is to throw an Exception. So a throw one, my question changes that what should i do with the exception??
php.net's manual is pretty confusing ! </p>
<pre><code> // Setup the user ( we assume he is a user first. referees, admins are considered users too )
try { $him = new user ($_emailAddress);
} catch (Exception $e_u) {
// try the groups database
try { $him = new group ($_emailAddress);
} catch (Exception $e_g) {
// email address was not in any of them !!
}
}
</code></pre>
| 0non-cybersec
| Stackexchange | 424 | 1,444 |
MySQL: Does access to table data not in an index via a join causes a file-sort when ordered. <p>The inclusion of category.name in the SELECT, causes the query to perform a
Using index; Using temporary; Using filesort, and also the rows scanned are not affected by the LIMIT 0,1.</p>
<pre><code>CREATE TABLE `item` (
`id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
PRIMARY KEY (`id`)
) ENGINE=INNODB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
CREATE TABLE `category` (
`id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
`name` VARCHAR(255) COLLATE utf8_unicode_ci NOT NULL DEFAULT '',
`created_at` TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP,
`updated_at` TIMESTAMP NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`id`)
) ENGINE=INNODB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
CREATE TABLE `feature` (
`id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
`item_id` INT(10) UNSIGNED DEFAULT NULL,
`category_id` INT(10) UNSIGNED DEFAULT NULL,
`start_date` DATE DEFAULT NULL,
`created_at` TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP,
`updated_at` TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`id`),
KEY `tbl_feature_id_item_id_foreign` (`item_id`),
KEY `tbl_feature_id_category_id_foreign` (`category_id`),
CONSTRAINT `tbl_feature_id_item_id_foreign` FOREIGN KEY (`item_id`) REFERENCES `item` (`id`),
CONSTRAINT `tbl_feature_id_category_id_foreign` FOREIGN KEY (`category_id`) REFERENCES `category` (`id`)
) ENGINE=INNODB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
INSERT INTO `item` (`id`) VALUES (1),(2),(3),(4),(5);
INSERT INTO `category` (`id`, `name`, `created_at`, `updated_at`)
VALUES
(1, 'a', '2016-12-02 22:49:46', NULL),
(2, 'b', '2016-12-02 22:49:48', NULL)
;
INSERT INTO `feature` (`id`, `item_id`, `category_id`, `start_date`, `created_at`, `updated_at`)
VALUES
(1, 1, 1, '2016-12-01', NOW(), NOW()),
(2, 1, 2, '2016-12-02', NOW(), NOW()),
(3, 2, 1, '2016-12-01', NOW(), NOW()),
(4, 2, 2, '2016-12-02', NOW(), NOW()),
(5, 3, 1, '2016-12-01', NOW(), NOW()),
(6, 3, 2, '2016-12-02', NOW(), NOW()),
(7, 4, 1, '2016-12-01', NOW(), NOW()),
(8, 4, 2, '2016-12-02', NOW(), NOW()),
(9, 5, 1, '2016-12-01', NOW(), NOW()),
(10, 5, 2, '2016-12-02', NOW(), NOW())
;
EXPLAIN EXTENDED
SELECT
item.id
, feature.id
, category.id
, category.name -- Is the cause of the temporary table; file-sort;
FROM
item
LEFT JOIN feature ON (
feature.item_id = item.id
AND feature.start_date = (
SELECT
MAX(start_date) AS start_date
FROM
feature
WHERE
feature.item_id = item.id
)
)
LEFT JOIN category ON (
category.id = feature.category_id
)
ORDER BY item.id DESC -- or ASC
LIMIT 0, 1 -- Is ignored in the table scan
;
</code></pre>
<p>MySQL 5.7.16</p>
<p><a href="https://i.stack.imgur.com/aQeGk.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/aQeGk.png" alt="enter image description here"></a></p>
<p>I believe it may be because of the need to access the source table after the sort is done. because the file-sort is performed in Mode 2</p>
<p><a href="http://s.petrunia.net/blog/?p=24" rel="nofollow noreferrer">http://s.petrunia.net/blog/?p=24</a></p>
<p><em>Mode 2: sort pairs and produce a sequence of rowids which one can use to get source table’s rows in the required order (but this will be essentially hit the table in random order and is not very fast)</em></p>
<p>Adding an index to category.name does resolve the issue. Is this is because category.name is now part of the index? </p>
<p>Can anybody confirm, and possibly provide a better solution than adding the index, as in reality, it does not resolve the issue as the point in time construct is repeated for multiple other features i.e. feature_a, feature_b. </p>
<p><strong>Why is Using index; Using temporary; Using filesort performed?</strong></p>
<p><strong>Why does the LIMIT 0,1 not affect the rows scanned?</strong></p>
| 0non-cybersec
| Stackexchange | 1,448 | 4,021 |
Missing 'lowerdir' on boot. <p>I did not perform any update on my system on Ubuntu 18.04.
On booting the system, I get error</p>
<blockquote>
<p>[24.537547] aufs aufs_fill_super:918:mount[1298]: no arg <br/>
[24.558603] overlayfs: missing 'lowerdir'</p>
</blockquote>
<p>I cannot load GRUB, because I get the same error instead of GRUB loading. So, I cannot boot in recovery mode. Hence, <a href="https://askubuntu.com/questions/1068588/boot-problem-after-update-missing-lowerdir">this answer</a> does not work.<br/>
However, I can access tty, and on running <code>df</code>, <code>/dev/sda1</code> mounted on <code>/</code> uses only 65% of total blocks.<br/>
I cannot seem to find a solution, what can I do?</p>
| 0non-cybersec
| Stackexchange | 245 | 722 |
Theorems in number theory whose first proofs were long and difficult. <p>What are the examples of important theorems of number theory that has been shown to have surprisingly simple proofs though their first demonstration wasn't at all simple enough. Now <em>simple proof</em> is an ambiguous term but in this case it may be defined as a proof which is both short and <a href="http://en.wikipedia.org/wiki/Elementary_proof" rel="nofollow">elementary</a>. As an example, the Kelly's proof of <a href="http://en.wikipedia.org/wiki/Sylvester%E2%80%93Gallai_theorem" rel="nofollow">Sylvester-Gallai Theorem</a> may be consdered. </p>
| 0non-cybersec
| Stackexchange | 171 | 631 |
simple select query in linq. <p>Lets say I have a student table and I want to display the student with ID 1.</p>
<pre><code>SELECT *
FROM STUDENT ST
WHERE ST.ID = 1
</code></pre>
<p>This is how I achive this in Linq.</p>
<pre><code>StudentQuery = from r in oStudentDataTable.AsEnumerable()
where (r.Field<int>("ID") == 1)
select r;
oStudentDataTable = StudentQuery.CopyToDataTable();
</code></pre>
<p>but what if I want to display the students with these ids 1,2,3,4,5..</p>
<pre><code>SELECT *
FROM STUDENT ST
WHERE ST.ID IN (1,2,3,4,5)
</code></pre>
<p>How can I achieve this in Linq?</p>
| 0non-cybersec
| Stackexchange | 235 | 689 |
Cancel Subscription At Period End. <p><strong>QUESTION:</strong></p>
<p>How does one append the "at_period_end" argument to the following PHP function in accordance with the relevant Stripe documentation ?</p>
<p><strong>DOCUMENTATION:</strong> </p>
<p><a href="https://stripe.com/docs/api/php#cancel_subscription" rel="noreferrer">STRIPE: cancel subscription</a></p>
<p><strong>CODE:</strong></p>
<pre><code><?php
require_once('./lib/Stripe.php');
Stripe::setApiKey("$APIKEY");
$cu = Stripe_Customer::retrieve("$CUSTOMER_ID");
$cu->subscriptions->retrieve("$SUBSCRIPTION_ID")->cancel();
?>
</code></pre>
| 0non-cybersec
| Stackexchange | 228 | 628 |
Linux LACP (802.3ad) working for ingress traffic only?. <p>We've setup LACP (802.3ad) on our Juniper switch and a Linux host, connected to the switch with 3x 1Gbps links. We are able to download from multiple sources at a rate of 3 Gbps, but when uploading files to different destinations, we get a maximum of 1 Gbps. Interestingly, only 1 uplink appears to be used by the Linux host to upload (to different destinations) :</p>
<pre><code>Interface: ge-0/0/34, Enabled, Link is Up
Encapsulation: Ethernet, Speed: 1000mbps
Traffic statistics:
Input bytes: 9874189047641 (981736896 bps)
Output bytes: 5641687864781 (440210816 bps)
Interface: ge-0/0/36, Enabled, Link is Up
Encapsulation: Ethernet, Speed: 1000mbps
Traffic statistics:
Input bytes: 6194266205 (1016 bps)
Output bytes: 5368956712475 (400087456 bps)
Interface: ge-0/0/44, Enabled, Link is Up
Encapsulation: Ethernet, Speed: 1000mbps
Traffic statistics:
Input bytes: 1494878289802 (1016 bps)
Output bytes: 11897014259103 (469673216 bps)
</code></pre>
<p>Input and output are flipped over.</p>
<p>We basically followed this tutorial : <a href="http://phreek.org/blog/2014/11/centos-7-lacp-network-bonding" rel="nofollow noreferrer">http://phreek.org/blog/2014/11/centos-7-lacp-network-bonding</a></p>
<p>And setup LACP as usual on our switch.</p>
<pre><code># show system rollback 2 compare 1
[edit chassis]
- aggregated-devices {
- ethernet {
- device-count 1;
- }
- }
[edit interfaces ge-0/0/34]
- ether-options {
- 802.3ad ae0;
- }
[edit interfaces ge-0/0/34]
+ unit 0 {
+ family ethernet-switching;
+ }
[edit interfaces ge-0/0/36]
- ether-options {
- 802.3ad ae0;
- }
[edit interfaces ge-0/0/36]
+ unit 0 {
+ family ethernet-switching;
+ }
[edit interfaces ge-0/0/44]
- ether-options {
- 802.3ad ae0;
- }
[edit interfaces ge-0/0/44]
+ unit 0 {
+ family ethernet-switching;
+ }
[edit interfaces]
- ae0 {
- aggregated-ether-options {
- lacp {
- active;
- periodic fast;
- }
- }
- unit 0 {
- family ethernet-switching;
- }
- }
[edit vlans SERVER-130 interface]
+ ge-0/0/44.0;
+ ge-0/0/36.0;
+ ge-0/0/34.0;
- ae0.0;
</code></pre>
<p>Any idea?</p>
| 0non-cybersec
| Stackexchange | 843 | 2,419 |
Introduction to Linear Algebra (Strang) Challenge Question. <p>I've been studying from Gilbert Strang's 1993 Linear Algebra text, and right in the first chapter, I've found a problem on dot products whose answer in the back is tough for me to make sense out of...</p>
<p>Question:</p>
<blockquote>
<p>Pick any numbers that add to x + y + z = 0. Find the angle between your vector v = (x, y, z) and the vector w = (z, x, y). Challenge Question: Explain why (v · w) / ||v||||w|| is always -1/2.</p>
</blockquote>
<p>The former part is easy. I found cos(angle) = -1/2 using v = (-1, -1, 2).</p>
<p>Answer given for the latter part: </p>
<blockquote>
<p>...Write v · w = xz + yz + xy as (1/2)(x + y + z)<sup>2</sup> - (1/2)(x<sup>2</sup> + y<sup>2</sup> + z<sup>2</sup>) whis is (-1/2)(x<sup>2</sup> + y<sup>2</sup> + z<sup>2</sup>).</p>
</blockquote>
<p>I tried rewriting it as suggested, which could make sense of that long middle term. It's is the final phrase "which is.." that throws me off. </p>
<p>Help so appreciated!</p>
| 0non-cybersec
| Stackexchange | 377 | 1,037 |
Font awesome percentage width stacked icon. <p>I want to achieve the following effect with CSS:</p>
<p><a href="https://i.stack.imgur.com/V2U7O.png" rel="noreferrer"><img src="https://i.stack.imgur.com/V2U7O.png" alt="enter image description here"></a></p>
<p>This star icon is a font. I would like to define the width of the orange background by percents, so 50% should be the perfect half of the star.</p>
<p>For now, I did the following:</p>
<pre><code><div class="container">
<span class="star star-under fa fa-star"></span>
<span class="star star-over fa fa-star"></span>
</div>
</code></pre>
<p>And:</p>
<pre><code>.container
{
font-size: 200px;
height: 300px;
position: relative;
width: 100%;
}
.star
{
display: inline-block;
left: 0;
position: absolute;
top: 0;
}
.star-under
{
color: #ddd;
}
.star-over
{
color: #f80;
overflow: hidden;
width: 30%;
}
</code></pre>
<p>The problem is that I need to provide the width and height in order to use % of width. And if I skip the container's width and height, it displays nothing, because it contains absolutely positioned children.</p>
<p>This % value is calculated on server side, so I'd rather keep it inline, like this:</p>
<pre><code><span class="star star-over fa fa-star" style="width: 62%;"></span>
</code></pre>
<p>What is the most flexible way to do this? By most flexible I mean the one that doesn't make it necessary to provide any width nor height.</p>
| 0non-cybersec
| Stackexchange | 521 | 1,534 |
Show Category table with parent categories. <p>Below is my table structure:</p>
<p><strong>Menu Table</strong></p>
<pre><code>id title position
--------------------
1 Test home
2 Test2 home
</code></pre>
<p><strong>Category</strong></p>
<pre><code>cid name parent parent_menu
--------------------------------
1 ABC 0 1
2 DEF 0 2
3 GHI 1 0
4 JKL 2 0
</code></pre>
<p><strong>Category Description</strong></p>
<pre><code>id cat_id catdesc slug
-------------------------------
1 1 ABC_DESC abc
2 2 DEF_DESC def
3 3 GHI_DESC ghi
4 4 JKL_DESC jkl
</code></pre>
<ul>
<li><code>Menu table</code> handles the menu title an position.</li>
<li><code>Category table</code> handles category name and other parameters. (if parent=0 then it means that this is main category and so on..)</li>
<li><code>Category Description table</code> handles the description, slug and other parameters.</li>
</ul>
<p>Now i want to display data like as below</p>
<pre><code> Name Description Edit Delete /*table headings*/
-------------------------------------------------------
Menu Title: (Test) Main Category Name: (ABC)
------------------------------------------------------
GHI GHI_DESC edit_icon delete_icon
______________________________________________________
Menu Title: (Test2) Main Category Name: (DEF)
------------------------------------------------------
JKL JKL_DESC edit_icon delete_icon
</code></pre>
<p>I tried to use JOINS and manipulate data in PHP but no luck.</p>
<pre><code>SELECT * FROM `category` t1 LEFT JOIN `category_description` t2 ON t1.cid = t2.cat_id WHERE 1
</code></pre>
<p>Then in PHP i tried like as below</p>
<pre><code><?php $i = 1; foreach($subcat as $sub) { ?>
<?php if($sub->parent == 0) { ?>
<tr><td><?php echo $sub->name ?></td></tr>
<?php } ?>
<?php if($sub->parent != 0) { ?>
<tr><td><?php echo $sub->name ?></td><td><?php echo $sub->catdesc ?></td>
<td>Edit</td><td>Delete</td></tr>
<?php } ?>
<?php } ?>
</code></pre>
<p>And above prints table like as below:</p>
<pre><code>Main Category Name: ABC
Main Category Name: DEF
------
GHI GHI_DESC
JKl JKL_DESC
</code></pre>
<p>Please suggest how to print as desired. </p>
| 0non-cybersec
| Stackexchange | 858 | 2,590 |
Subsets and Splits