Integrate Airy function from 0 to $\infty$

Question: From the integral representation of Airy function
$$\mathrm{Ai}(x)=\int_{-\infty}^{\infty} \frac{\mathrm{d} \tau}{2\pi} \exp(-\mathrm{i}\tau x)\exp(-\mathrm{i}\frac{\tau^3}{3}),$$
It is easy to see that $\int_{-\infty}^{\infty} \mathrm{d} x\mathrm{Ai}(x) =1$. However, I am wondering how to find
$$\int_{0}^{\infty} \mathrm{d}x \mathrm{Ai}(x).$$
From this website, the result of the above integral is $\frac{1}{3}.$ I could not follow the method in the reference given by that website. Could anyone give an alternative (more straightforward) derivation of  $\int_{0}^{\infty} \mathrm{d}x \mathrm{Ai}(x)=\frac{1}{3}$?
Answer: Given the integral representation it follows that $\text{Ai}(x)$ fulfills the differential equation $y''=x y$.
In particular $\text{Ai}(x)$ is an entire function and
$$\text{Ai}(x)=\frac{1}{\pi}\int_{0}^{+\infty}\cos\left(\frac{t^3}{3}+xt\right)\,dt \tag{1}$$
$$\begin{eqnarray*}(\mathcal{L}\text{Ai})(s)&=&\frac{1}{\pi}\int_{0}^{+\infty}\int_{0}^{+\infty}\cos\left(\frac{t^3}{3}+xt\right)e^{-sx}\,dt\,dx\\&=&\frac{1}{\pi}\int_{0}^{+\infty}\frac{s\cos\left(\frac{t^3}{3}\right)-t\sin\left(\frac{t^3}{3}\right)}{s^2+t^2}\,dt \tag{2}\end{eqnarray*}$$
It is not difficult to show that
$$ \lim_{s\to 0^+}\int_{0}^{+\infty}\cos\left(\frac{t^3}{3}\right)\frac{s\,dt}{s^2+t^2} = \frac{\pi}{2}\tag{3}$$
$$ \lim_{s\to 0^+}\int_{0}^{+\infty}\sin\left(\frac{t^3}{3}\right)\frac{t\,dt}{s^2+t^2} = \frac{\pi}{6}\tag{4}$$
and it follows that
$$ \int_{0}^{+\infty}\text{Ai}(x)\,dx = \lim_{s\to 0^+}\left(\mathcal{L}\text{Ai}\right)(s) = \frac{1}{\pi}\left(\frac{\pi}{2}-\frac{\pi}{6}\right)=\color{red}{\frac{1}{3}}\tag{5} $$
as wanted.
Comment: @JackD'Aurizio Hi Jack.  I hope that you're doing well.  In the answer I posted, I took a few liberties with formal manipulations without justifying them.  It seems you did likewise.  So, here is a question.  (1) How does one justify the interchange of integration you used in your development?  Fubini-Tonelli does not apply here.  So, what other ways could one proceed?
Comment: The method is deceptively simple but it is not! (a) The change of order of integration needs justification. (b) The conclusion from Laplace transform is not justified (the target integral is shown to be in fact convergent, although it is well known to be the case) (c) the limit for the integral in (4) is not justified (dominated convergence does not apply here since the integrand is not Lebesgue integrable).
Comment: Thank you for your help! Is this method a common technique to evaluate integral from 0 to $\infty$?
Comment: @ZHW: I'd say so but I am partial to that: every time I see an integral of the form $\int_{0}^{+\infty}(\ldots)\,dx$ I think about simplifying it through the Laplace (inverse) transform.
Answer: $$\begin{align}
\frac1{2\pi}\int_0^L \int_{-\infty}^\infty e^{-itx}e^{-it^3/3}\,dt\,dx&=\frac1{2\pi}\int_{-\infty}^\infty \left(\int_0^L e^{-itx}\,dx \right)\,e^{-it^3/3}\,dt\\\\
&=\frac1{2\pi i}\int_{-\infty}^\infty \left(\frac{1-e^{-iLt}}{t} \right)\,e^{-it^3/3}\,dt\\\\
&=\frac1{\pi }\int_{0}^\infty \frac{\sin(Lt)}{t}\,\cos(t^3/3)\,dt-\frac1{\pi }\int_{0}^\infty \frac{1-\cos(Lt)}{t}\,\sin(t^3/3)\,dt
\end{align}$$
It is straightforward (See the analysis in the OP of this question ) to show that
$$\lim_{L\to \infty}\int_{0}^\infty \frac{\sin(Lt)}{t}\,\cos(t^3/3)\,dt=\frac{\pi}{2}$$
and that
$$\lim_{L\to \infty}\int_{0}^\infty \frac{1-\cos(Lt)}{t}\,\sin(t^3/3)\,dt=\frac{\pi}{6}$$
Putting everything together reveals
$$\int_0^\infty \text{Ai}(x)\,dx=\frac13$$
as was to be shown!

Alternatively, we can use distributions and write
$$\begin{align}
\frac1{2\pi}\int_0^\infty \int_{-\infty}^\infty e^{-itx}e^{-it^3/3}\,dt\,dx&=\frac1{2\pi}\int_{-\infty}^\infty \left(\int_0^\infty e^{-itx}\,dx \right)\,e^{-it^3/3}\,dt\\\\
&=\frac1{2\pi }\text{PV}\left(\int_{-\infty}^\infty \left(\pi \delta(t)+\frac{1}{it} \right)\,e^{-it^3/3}\,dt\right)\\\\
&=\frac12-\frac1{2\pi }\int_{-\infty}^\infty \frac{\sin(t^3/3)}{t} \,dt\\\\
&=\frac12-\frac16\\\\
&=\frac13
\end{align}$$
as expected!
Comment: Thank you for the help! For those two integrals in your first answer, I suppose the $\lim_{L\rightarrow \infty}$ operation is taken before the integration, in order to get rid of terms with $t^3/3$. Am I correct about this? Besides, may I know more about distributions in your second answer? I am not so familiar with it, but would like to learn more.
Comment: You're welcome.  The limit is taken after the integration.  We cannot bring the limit inside the integral since the limit of the integrand fails to exist.  [HERE](https://en.wikipedia.org/wiki/Distribution_(mathematics)) is an article on distributions.
Answer: I don't know if this is the approach discussed in the reference, but the Airy function $\operatorname{Ai}(x)$ can be expressed in terms of the  modified Bessel function of the second kind of order $\pm \frac{1}{3}$:
$$\operatorname{Ai}(x)= \frac{1}{\pi} \sqrt{\frac{x}{3}} K_{\pm 1/3} \left(\frac{2}{3} x^{3/2} \right), \quad x>0 . \tag{1}$$
And an integral representation of the modified Bessel function of the second kind is $$K_{\nu}(x) = \frac{1}{2} \left(\frac{x}{2} \right)^{\nu} \int_{0}^{\infty}\exp\left(-t-\frac{x^{2}}{4t} \right) \, \frac{\mathrm dt}{t^{\nu+1}}, \quad  x>0, \tag{2} $$
which can be derived from the integral representation $$K_{\nu}(x) =\int_{0}^{\infty} \exp(-x\cosh t) \cosh(\nu t) \, \mathrm dt = \frac{1}{2} \int_{-\infty}^{\infty} \exp\left(-x \cosh t\right) e^{-\nu t} \, \mathrm dt $$ by making the substitution $e^{t}= \frac{2}{x}u$.
Using $(1)$ and $(2)$, and assuming that $a>0$, we have
$$ \begin{align}I(a) &= \int_{0}^{\infty} x^{a-1} \operatorname{Ai}(x) \, \mathrm dx \\ &= \frac{1}{\pi \sqrt{3}}\int_{0}^{\infty} x^{a-1/2} \, K_{1/3}\left(\frac{2}{3}x^{3/2} \right) \, \mathrm dx \\ &=\frac{1}{\pi} \, \frac{3^{2a/3-7/6}}{ 2^{2a/3-2/3}} \int_{0}^{\infty} u^{2a/3-2/3} K_{1/3}(u) \, \mathrm du  \\  &= \frac{1}{\pi} \, \frac{3^{2a/3-7/6}}{ 2^{2a/3-2/3}}\int_{0}^{\infty} u^{2a/3-2/3} \, \frac{1}{2} \left(\frac{u}{2} \right)^{1/3} \int_{0}^{\infty} \exp \left(-t - \frac{u^{2}}{4t}\right) \, \frac{\mathrm dt}{t^{4/3}} \, \mathrm du \\ &= \frac{1}{\pi} \, \frac{3^{2a/3-7/6}}{ 2^{2a/3+2/3}}\int_{0}^{\infty}\frac{e^{-t}}{t^{4/3}} \int_{0}^{\infty}u^{2a/3-1/3} \exp \left(- \frac{u^{2}}{4t} \right) \, \mathrm du \, \mathrm dt  \tag{1}\\ &= \frac{3^{2a/3-7/6}}{2 \pi}\int_{0}^{\infty} t^{a/3-1} e^{-t} \int_{0}^{\infty} w^{a/3-2/3} e^{-w} \, \mathrm dw  \, \mathrm  dt \\ &= \frac{3^{2a/3-7/6}}{2 \pi}\Gamma\left(\frac{a+1}{3}\right)  \int_{0}^{\infty} t^{a/3-1} e^{-t} \, \, \mathrm dt \\&= \frac{3^{2a/3-7/6}}{2 \pi} \, \Gamma \left(\frac{a+1}{3} \right) \Gamma \left(\frac{a}{3} \right).  \end{align}$$

$(1)$ Since the integrand is nonnegative, Tonelli's theorem allows us to change the order of integration.

Therefore,  $$\begin{align} \int_{0}^{\infty} \operatorname{Ai}(x) \, \mathrm dx &= I(1) \\ &= \frac{1}{2\pi \sqrt{3}} \, \Gamma \left(\frac{2}{3} \right) \Gamma \left(\frac{1}{3} \right)\\ &= \frac{1}{2 \sqrt{3}} \, \pi \csc \left(\frac{\pi }{3} \right)  \\ &=\frac{1}{2 \sqrt{3}} \left(\frac{2}{\sqrt{3}} \right) \\ &= \frac{1}{3}. \end{align}$$

As a side note, if we express $\operatorname{Ai}(x)$ in terms of $K_{-1/3}(z)$ and  use $(2)$, we get the integral representation $$ \begin{align} \operatorname{Ai}(x) &= \frac{1}{\pi} \sqrt{\frac{x}{3}} \frac{1}{2} \left(\frac{x^{3/2}}{3} \right)^{-1/3} \int_{0}^{\infty} \exp \left(-t-\frac{x^{3}}{9t} \right) \frac{\mathrm dt}{t^{2/3}}  \\ &= \frac{\sqrt{3}}{2 \pi} \int_{0}^{\infty} \exp \left(- \frac{u^{3}}{3} - \frac{x^{3}}{3u^{3}} \right) \, \mathrm du. \end{align}$$
Answer: $\newcommand{\bbx}[1]{\,\bbox[15px,border:1px groove navy]{\displaystyle{#1}}\,}
 \newcommand{\braces}[1]{\left\lbrace\,{#1}\,\right\rbrace}
 \newcommand{\bracks}[1]{\left\lbrack\,{#1}\,\right\rbrack}
 \newcommand{\dd}{\mathrm{d}}
 \newcommand{\ds}[1]{\displaystyle{#1}}
 \newcommand{\expo}[1]{\,\mathrm{e}^{#1}\,}
 \newcommand{\ic}{\mathrm{i}}
 \newcommand{\mc}[1]{\mathcal{#1}}
 \newcommand{\mrm}[1]{\mathrm{#1}}
 \newcommand{\pars}[1]{\left(\,{#1}\,\right)}
 \newcommand{\partiald}[3][]{\frac{\partial^{#1} #2}{\partial #3^{#1}}}
 \newcommand{\root}[2][]{\,\sqrt[#1]{\,{#2}\,}\,}
 \newcommand{\totald}[3][]{\frac{\mathrm{d}^{#1} #2}{\mathrm{d} #3^{#1}}}
 \newcommand{\verts}[1]{\left\vert\,{#1}\,\right\vert}$

$\ds{\mrm{Ai}\pars{x} =
\int_{-\infty}^{\infty}{\dd\tau \over 2\pi}\,\exp\pars{-\ic\tau x}
\exp\pars{-\ic\,{\tau^{3} \over 3}}\,,
\qquad\qquad\int_{0}^{\infty}\mrm{Ai}\pars{x}\,\dd x:\ {\large ?}}$.

\begin{align}
&\int_{0}^{\infty}\mrm{Ai}\pars{x}\,\dd x =
\int_{-\infty}^{\infty}\mrm{H}\pars{x}\mrm{Ai}\pars{x}\,\dd x\qquad\qquad
\pars{~\substack{\ds{\mrm{H}:\mathbb{R}\setminus\braces{0} \to \mathbb{R}}}
\\[3mm] {Heaviside\ Step\ Function}~}
\\[5mm] = &\
\int_{-\infty}^{\infty}\overbrace{\pars{\int_{-\infty}^{\infty}
{\expo{\ic \tau x} \over \tau - \ic 0^{+}}
\,{\dd \tau \over 2\pi\ic}}}^{\ds{\mrm{H}\pars{x}}}\
\mrm{Ai}\pars{x}\,\dd x\qquad\
\pars{~\substack{\mbox{Note that}
\\[2mm]
\ds{\left.\vphantom{\Large A}\mrm{H}\pars{x}\right\vert_{\ x\ \not=\ 0} =
\lim_{\epsilon \to 0^{+}}\int_{-\infty}^{\infty}
{\expo{\ic \tau x} \over \tau - \ic\epsilon}
\,{\dd \tau \over 2\pi\ic}}}~}
\\[5mm] = &\
\int_{-\infty}^{\infty}{1 \over \tau - \ic 0^{+}}
\bracks{\int_{-\infty}^{\infty}\mrm{Ai}\pars{x}\expo{\ic\tau x}\,\dd x}
\,{\dd\tau \over 2\pi\ic} =
\int_{-\infty}^{\infty}{\exp\pars{-\ic\tau^{3}/3} \over \tau - \ic 0^{+}}
\,{\dd\tau \over 2\pi\ic}
\\[5mm] = &\
\mrm{P.V.}\int_{-\infty}^{\infty}{\exp\pars{-\ic\tau^{3}/3} \over \tau}
\,{\dd\tau \over 2\pi\ic} + {1 \over 2} =
-\,{1 \over \pi}\int_{0}^{\infty}{\sin\pars{\tau^{3}/3} \over \tau}\,\dd\tau +
{1 \over 2}
\\[5mm] \stackrel{\large\tau^{3}/3\ \mapsto\ \tau}{=}\,\,\,&
-\,{1 \over 3\pi}\int_{0}^{\infty}{\sin\pars{\tau} \over \tau}\,\dd\tau +
{1 \over 2} =
-\,{1 \over 3\pi}\,{\pi \over 2} + {1 \over 2} = \bbx{1 \over 3}
\end{align}


I don't want to type directly the key of application insight to register log

Question: I don't want to type the key of application insight in the Program.cs, Can I type it in some file of configurations or in another place? It's a ASP .Net Core
I want to include a register in application insights of my logs but with modifications. Now I have a register, but I am typing the key in the Program.cs and I have "a problem" when I change of environment. Do you know any way to type this key dynamicly on the Program.cs or can I do this declaration in another place of the program.
This is the Program.cs. It started with the Main and after it starts the BuildWebHost where I load the key of applications insights and it's what I want to change:
    public static IWebHost BuildWebHost(string[] args) =>
        WebHost.CreateDefaultBuilder(args)
        .UseStartup<Startup>()
        .ConfigureLogging(logging =>
        {
                logging.AddApplicationInsights("db0fe38d-c208-8ed7-23e4ef4479bb");

                // Optional: Apply filters to configure LogLevel Trace or above is sent to
                // ApplicationInsights for all categories.
                logging.AddFilter<ApplicationInsightsLoggerProvider>("", LogLevel.Trace);

                // Additional filtering For category starting in "Microsoft",
                // only Warning or above will be sent to Application Insights.
                logging.AddFilter<ApplicationInsightsLoggerProvider>("Microsoft", LogLevel.Warning);
        }).Build();

How I said, I would avoid to type key on the Program and I would like take this param from a config file or type this declaration in another place
Comment: it's a .net core web application?
Comment: @IvanYang Yes, it's
Answer: Since it is an ASP.NET Core application, you can use the ConfigureLogging extension method that injects the WebHostBuilderContext to retrieve your configuration:
 public static IWebHost BuildWebHost(string[] args) =>
        WebHost.CreateDefaultBuilder(args)
        .UseStartup<Startup>()
        .ConfigureLogging((hostingContext, logging) =>
        {
                var appInsightKey =  hostingContext.Configuration["MyAppInsight"];
                logging.AddApplicationInsights(appInsightKey);

                // Optional: Apply filters to configure LogLevel Trace or above is sent to
                // ApplicationInsights for all categories.
                logging.AddFilter<ApplicationInsightsLoggerProvider>("", LogLevel.Trace);

                // Additional filtering For category starting in "Microsoft",
                // only Warning or above will be sent to Application Insights.
                logging.AddFilter<ApplicationInsightsLoggerProvider>("Microsoft", LogLevel.Warning);
        }).Build();

Comment: When I typed .ConfigureLogging I have a Error: Adds a delegate for configuring the provided ILoggingBuilder. Cannot resolve method ConfigureLogging
Comment: I probably missed the parentheses: `(hostingContext, logging)`. I updated my answer.
Answer: Just add UseApplicationInsights(), then remove the instrumentation key(assume the instrumentation key set in the appsettings.json).
Sample code as below, and works well at my side:
        public static IWebHost BuildWebHost(string[] args) =>
        WebHost.CreateDefaultBuilder(args)
        .UseApplicationInsights()  // add this line of code, and it will auto-read ikey from appsettings.json.
        .UseStartup<Startup>()
        .ConfigureLogging(logging =>
        {
            //then you can remove instrumentation key from here.
            logging.AddApplicationInsights();
            logging.AddFilter<ApplicationInsightsLoggerProvider>("", LogLevel.Trace);

            logging.AddFilter<ApplicationInsightsLoggerProvider>("Microsoft", LogLevel.Warning);
        }).Build();

Comment: adding UseApplicationInsights() to just read ikey from appsettings.json has possibly unintended side effects, as this method enables Request/Dependency monitoring.
Comment: @cijothomas, could you please explain more about "this method enables Request/Dependency monitoring"? thanks. I thought app insights always monitor request/dependency.
Comment: UseApplicationInsights() extension method on IWebHostBuilder, enables entire application insights monitoring - requests/dependencies/counters etc. The AddApplicationInsights() extension method on loggingBuilder just enables ILogger log capture. If the intent is to capture ilogger logs only, then the answer below by @martinbrandl is correct.


Error Installing Lubuntu Over Ubuntu – Please Help!

Question: I am (barely) running Ubuntu 10.10 on an ancient laptop.  I tried to install Lubuntu over it (and hopefully remove Ubuntu) by running this in the terminal – sudo apt-get install --no-install-recommends lubuntu-desktop (which I found in the Documentation).
About 10 minutes of code ran in the terminal and ended with something like this: (my user name)(my PC name):$.  This is not the exact final line in the terminal, but it is close.  At this point I had no idea what to do to complete the Lubuntu installation or close the terminal window.  I tried putting in my password and this did nothing, so I rebooted.  The result was that Ubuntu came up with no sign of Lubuntu.  What did I do wrong?
Answer: First of all
Did you remove the ubuntu components as it says here on the site you linked?
Second of all
If you don't mind losing any data, you could follow this tutorial, create a bottable CD and/or flash drive, and run the lubuntu install from there.
Answer: You forgot to remove ubuntu-desktop related packages from your system.
You should run:
remove acpi-support acpid adium-theme-ubuntu aisleriot apg app-install-data app-install-data-partner appmenu-gtk appmenu-gtk3 appmenu-qt apt-xapian-index apturl apturl-common at-spi2-core avahi-autoipd bamfdaemon banshee banshee-extension-soundmenu banshee-extension-ubuntuonemusicstore baobab binfmt-support bluez-alsa bluez-cups bluez-gstreamer branding-ubuntu brasero brasero-cdrkit brasero-common brltty c2esp checkbox checkbox-gtk cli-common compiz compiz-core compiz-gnome compiz-plugins-default compiz-plugins-main-default compizconfig-backend-gconf cups-bsd dc deja-dup dmz-cursor-theme doc-base duplicity dvd+rw-tools empathy empathy-common eog espeak espeak-data evolution-data-server evolution-data-server-common example-content exiv2 firefox firefox-globalmenu firefox-gnome-support foo2zjs gamin gbrainy gcalctool gcc gcc-4.6 gedit gedit-common geoclue geoclue-ubuntu-geoip ghostscript-x ginn gir1.2-atspi-2.0 gir1.2-gconf-2.0 gir1.2-gmenu-3.0 gir1.2-gtksource-3.0 gir1.2-indicate-0.6 gir1.2-launchpad-integration-3.0 gir1.2-peas-1.0 gir1.2-totem-1.0 gir1.2-totem-plparser-1.0 gir1.2-wnck-3.0 gnome-accessibility-themes gnome-codec-install gnome-control-center gnome-control-center-data gnome-desktop3-data gnome-font-viewer gnome-games-common gnome-icon-theme-symbolic gnome-mahjongg gnome-media gnome-menus gnome-nettool gnome-online-accounts gnome-orca gnome-power-manager gnome-screensaver gnome-screenshot gnome-search-tool gnome-session gnome-session-bin gnome-session-canberra gnome-session-common gnome-settings-daemon gnome-sudoku gnome-system-log gnome-system-monitor gnome-terminal gnome-terminal-data gnome-utils-common gnomine growisofs gstreamer0.10-alsa gstreamer0.10-gconf gstreamer0.10-plugins-base-apps gstreamer0.10-pulseaudio gstreamer0.10-tools guile-1.8-libs gwibber gwibber-service gwibber-service-facebook gwibber-service-identica gwibber-service-twitter hplip hplip-cups hplip-data hwdata ibus ibus-gtk ibus-gtk3 ibus-pinyin ibus-pinyin-db-android ibus-pinyin-db-open-phrase ibus-table im-switch indicator-appmenu indicator-datetime indicator-power indicator-session indicator-sound inputattach intel-gpu-tools kerneloops-daemon lftp libappindicator0.1-cil libasound2-plugins libatk-adaptor libatspi2.0-0 libavahi-gobject0 libbamf0 libbamf3-0 libboost-serialization1.46.1 libbrasero-media3-1 libbrlapi0.5 libc-dev-bin libc6-dev libcamel-1.2-29 libcanberra-pulse libcompizconfig0 libcrypt-passwdmd5-perl libdbus-glib1.0-cil libdbus1.0-cil libdbusmenu-qt2 libdconf-dbus-1-0 libdconf-qt0 libdconf0 libdecoration0 libdotconf1.0 libebackend-1.2-1 libebook1.2-12 libecal1.2-10 libedata-book-1.2-11 libedata-cal-1.2-13 libedataserver1.2-15 libedataserverui-3.0-1 libespeak1 libexempi3 libexiv2-10 libfile-copy-recursive-perl libfolks-telepathy25 libfolks25 libgail-3-common libgail-common libgamin0 libgconf2.0-cil libgd2-xpm libgdata-common libgdata1.7-cil libgdata13 libgdiplus libgeoclue0 libgexiv2-0 libgkeyfile1.0-cil libglew1.5 libglewmx1.5 libglib2.0-bin libglib2.0-cil libglib2.0-data libgmime-2.4-2 libgmime2.4-cil libgnome-control-center1 libgnome-desktop-3-2 libgnome-media-profiles-3.0-0 libgnome-menu-3-0 libgnome-menu2 libgnome2-common libgnomekbd-common libgnomekbd7 libgnomevfs2-0 libgnomevfs2-common libgoa-1.0-0 libgomp1 libgtk-sharp-beans-cil libgtk-vnc-2.0-0 libgtk2.0-cil libgtkmm-3.0-1 libgtksourceview-3.0-0 libgtksourceview-3.0-common libgtkspell3-0 libgudev1.0-cil libgvnc-1.0-0 libgweather-3-0 libgweather-common libgwibber-gtk2 libgwibber2 libhyphen0 libibus-1.0-0 libidl0 libido3-0.1-0 libjson-glib-1.0-0 liblaunchpad-integration1.0-cil liblightdm-gobject-1-0 liblouis-data liblouis2 libmetacity-private0 libmission-control-plugins0 libmng1 libmono-addins-gui0.2-cil libmono-addins0.2-cil libmono-cairo4.0-cil libmono-corlib4.0-cil libmono-csharp4.0-cil libmono-i18n-west4.0-cil libmono-i18n4.0-cil libmono-posix4.0-cil libmono-security4.0-cil libmono-sharpzip4.84-cil libmono-system-configuration4.0-cil libmono-system-core4.0-cil libmono-system-drawing4.0-cil libmono-system-security4.0-cil libmono-system-xml4.0-cil libmono-system4.0-cil libmono-zeroconf1.0-cil libmysqlclient16 libmythes-1.2-0 libnotify-bin libnotify0.4-cil libnux-1.0-0 libnux-1.0-common liboauth0 libopencc1 liborbit2 liboverlay-scrollbar-0.2-0 liboverlay-scrollbar3-0.2-0 libpeas-1.0-0 libpeas-common libprotobuf7 libprotoc7 libpulse-mainloop-glib0 libqt4-dbus libqt4-declarative libqt4-network libqt4-opengl libqt4-script libqt4-sql libqt4-sql-mysql libqt4-svg libqt4-xml libqt4-xmlpatterns libqtbamf1 libqtcore4 libqtdee2 libqtgconf1 libqtgui4 libquadmath0 libquvi0 libraptor2-0 librasqal3 librdf0 libreoffice-base-core libreoffice-calc libreoffice-common libreoffice-core libreoffice-draw libreoffice-emailmerge libreoffice-gnome libreoffice-gtk libreoffice-help-en-us libreoffice-impress libreoffice-math libreoffice-style-human libreoffice-writer librest-0.7-0 librsync1 libsane-hpaio libsdl1.2debian-pulseaudio libspeechd2 libspeexdsp1 libstlport4.6ldbl libsyncdaemon-1.0-1 libtaglib2.0-cil libtelepathy-farsight0 libtelepathy-logger2 libtextcat-data libtextcat0 libtotem-plparser17 libtotem0 libubuntuone-1.0-1 libubuntuone1.0-cil libunique-1.0-0 libunity-2d-private0 libunity-core-4.0-4 libunity-misc4 libutempter0 libuuid-perl libwmf0.2-7-gtk libwnck-3-0 libwnck-3-common libwnck-common libwnck22 libxp6 libxres1 libyajl1 libyaml-tiny-perl libzeitgeist-1.0-1 light-themes lightdm linux-libc-dev make media-player-info metacity metacity-common mono-4.0-gac mono-gac mono-runtime mousetweaks mscompress mysql-common nautilus nautilus-sendto nautilus-sendto-empathy nautilus-share notify-osd notify-osd-icons nux-tools onboard oneconf openprinting-ppds overlay-scrollbar pinyin-database pkg-config plymouth-theme-ubuntu-logo protobuf-compiler ptouch-driver pulseaudio pulseaudio-esound-compat pulseaudio-module-bluetooth pulseaudio-module-gconf pulseaudio-module-x11 pulseaudio-utils pxljr python-brlapi python-configglue python-dateutil python-egenix-mxdatetime python-egenix-mxtools python-farsight python-gconf python-ibus python-imaging python-indicate python-libproxy python-louis python-openssl python-pam python-papyon python-pexpect python-piston-mini-client python-protobuf python-pyatspi2 python-pyinotify python-serial python-speechd python-telepathy python-twisted-bin python-twisted-core python-twisted-names python-twisted-web python-ubuntuone-client python-ubuntuone-control-panel python-ubuntuone-storageprotocol python-uno python-virtkey python-webkit python-wnck qdbus qt-at-spi radeontool rastertosag-gdi rdesktop rfkill rtkit sane-utils seahorse shotwell sni-qt software-center speech-dispatcher splix ssh-askpass-gnome syslinux syslinux-common telepathy-butterfly telepathy-gabble telepathy-haze telepathy-idle telepathy-indicator telepathy-logger telepathy-mission-control-5 telepathy-salut thunderbird thunderbird-globalmenu thunderbird-gnome-support tomboy toshset totem totem-common totem-mozilla totem-plugins ttf-opensymbol ubufox ubuntu-artwork ubuntu-desktop ubuntu-docs ubuntu-mono ubuntu-sounds ubuntu-sso-client ubuntu-system-service ubuntu-wallpapers ubuntuone-client ubuntuone-client-gnome ubuntuone-control-panel ubuntuone-control-panel-gtk ubuntuone-couch ubuntuone-installer unity unity-2d unity-2d-launcher unity-2d-panel unity-2d-places unity-2d-spread unity-asset-pool unity-common unity-greeter unity-lens-applications unity-lens-files unity-lens-music unity-scope-musicstores unity-services uno-libs3 update-inetd ure usb-creator-common usb-creator-gtk vinagre vino whois wodim xbitmaps xcursor-themes xdg-user-dirs-gtk xdiagnose xfonts-mathml xterm xul-ext-ubufox zeitgeist zeitgeist-core zeitgeist-datahub zeitgeist-extension-fts zenity zenity-common && sudo apt-get install ubuntu-minimal lubuntu-desktop

Please copy from start to end. Also please consider upgrading your system since Lubuntu 10.10 reached EOL.
The highway
If you have the backup of all you important data, you can install Lubuntu 12.10 directly, since the upgrade process will be very slow and it isn't guaranteed that it will succeed. Following the instructions to download and install Lubuntu from the official page.


Will my OS be formatted if I partition my home directory in recovery mode?

Question: Will my OS be formatted if I partition my home directory in recovery mode? The question is for Ubuntu 14.04.
Answer: Asumming the root partition (/ partition) is installed on a separate  partition, the answer is no, you should be fine to go! Just to make sure take a look at the fstab file with the command: cat /etc/fstab just to give you a example you should look for something like:
 /dev/sda1 /
/dev/sda2 /home

or
UUID=a /

UUID=b /home

where a is not equal to b.


How to download file from wwwroot folder in dot core api using Mediatr pattern?

Question: I am trying to download wwwroot file where file is saved i want to download file by filename only which i am sending from my angular code.
in controller my code is like this
[HttpPost("DownloadMPWorthyFile")]
        public async Task<ActionResult<bool>> DownloadMPWorthyFile(DownloadMPWorthyFileCommand command)
        {
            return await Mediator.Send(command);
        }

in DownloadMPWorthyFileCommand  command i have added
using AutoMapper;
using Kaizen.Common.Interfaces;
using Kaizen.Common.Logger;
using MediatR;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Kaizen.Domain.Entities;
using Kaizen.Application.Common.Services.EmailService;
using EmailActions = Kaizen.Domain.Enums.EmailActions.Actions;
using Kaizen.Common.Models;
using Microsoft.Extensions.Options;
using Microsoft.AspNetCore.Hosting;

namespace Kaizen.Application.Kaizen.Command
{
    public class DownloadMPWorthyFileCommand : IRequest<bool>
    {
        public string FileName { get; set; }
        public string PageName { get; set; }
        public string IdeaNumber { get; set; }
    }

    public class GetKaizenDownloadfileResponse
    {
        public int StatusCode { get; set; }
        public string Message { get; set; }
        public string ErrorMessage { get; set; }
        public List<getdata> Data { get; set; }
    }

    public class getdata
    {
        public string FileName { get; set; }
        public string Method { get; set; }
        public string PageName { get; set; }
    }
    public class DownloadMPWorthyFileCommandHandle : IRequestHandler<DownloadMPWorthyFileCommand, bool>
    {
        private readonly IKaizenDBContext _context;
        private readonly IMapper _mapper;
        private readonly ILogger<kaizenUploadFile> _logger;
        private readonly IEmailService _emailService;
        private IHostingEnvironment Environment;
        public DownloadMPWorthyFileCommandHandle(IKaizenDBContext context, IMapper mapper, ILogger<SendMailForMPWorthyCommandHandler> logger, IEmailService emailService, IOptions<AppSettings> appSettings, IHostingEnvironment _environment)
        {
            _context = context;
            _mapper = mapper;
            //_logger = logger;
            _emailService = emailService;
            Environment = _environment;

           // _appSettings = appSettings.Value;
        }

        public async Task<bool> Handle(DownloadMPWorthyFileCommand request, CancellationToken cancellationToken)
        {
            bool retval = false;
            var MPWorthyFile = _context.DocumentUploaded.Where(e => e.IdeaNumber == request.IdeaNumber && e.PageName==request.PageName);
            if (MPWorthyFile != null)
            {
                string wwwPath1 = this.Environment.WebRootPath;
                string imgnm1 = "/document/" + request.FileName;
                string filePath1 = wwwPath1 + imgnm1;
                string imageName1 = filePath1;

                var net1 = new System.Net.WebClient();
                var path1 = wwwPath1 + filePath1;
                var data1 = net1.DownloadData(filePath1);
                var content1 = new System.IO.MemoryStream(data1);
                retval= true;
            }
            else
            {
                retval = false;
            }
            return retval;
        }
    }

}

i have done code in this way but its not working in return type i keep getting error,is anyone know correct way to download the file from wwwroot?
Answer: You should check the IHostingEvironment, there is an WebRootFileProvider with which you check for file and open stream on those.
var file = _environment.WebRootFileProvider.GetFileInfo("...");
if (file.Exists)
{
    var stream = file.CreateReadStream();
    // Go on from here...
}


STM32L + ENC28J60 (Olimex)

Question: I've got a problem with connecting ENC28J60-H by Olimex to my STM32L-Discovery.
So I write the code, that read an ECON1 register, thatn write some value into it and that read it again. And here is a problem: when i use a debugger step-by-step (F10) each line in this code, everything goes well. But when I set a breakpoint after this lines, register returns me 0x00.
I decided, that ENC just don't have enough time to write values into register. But manual says, that it has its own crystal osillator with frequency 20 or 25 MHz (don't remember exactly). And my frequency is about 150 kHz.
Anyway, I set a Delay (simple counter in the loop) after each SPI-sending or recieving. And that's helped.
Then I go ahead. I write an Init-function (soft-reset, than writing needed values into register), use it in main function. After calling it, I read a ECON1 register again. And I all i got is 0x00 again, even with Delays.
Does anybody know what to do in this situation?
Answer: After sending a byte thru SPDR then test the SPIF bit (0x80) in the SPSR register.  When SPIF == 1 then the data has been sent.
A delay works because you are giving the transmission (and internal logic in the ENC28J60) time to complete.

STM32L + ENC28J60 (Olimex)


Mounting an in home network cabinet without two studs, maybe use plywood?

Question: first post, I need some help. I am attempting to hang a 12u network cabinet in my laundry room. The problem is I only have one stud to use, maybe an additional corner stud, but the other stud is already taken up with some cabinets. I am trying to figure out best how to hang this, it is going to be around 50-60 pounds.
I have thought about getting a plywood sheet, and cutting it so it would have arms to go around the cabinets and I can attach the arms to the stud I cannot otherwise reach, and also attach to the other studs. But then how best would I mount the cabinet on the 3/4" plywood? Drywall would be behind plywood, and I am working with wooden studs.
Please help, hoping to get this hung today. Thanks.
Comment: Please post pictures of the cabinet and the space. Why does it need to be hung? Is this not something that can rest (on legs) on the floor with just a wall anchor to prevent tipping?
Comment: Hari, I'd like to mount it in front of the patch panel for aesthetics and cable management.
Answer: Your posting is a bit short on details but here is what you want to do.
Cut the 3/4 inch plywood so that it is at least the height of the cabinet and as wide as the space from the corner of the room over to the side of the existing other cabinets.
You will mount this rectangle of plywood flat against the wall with one side of it snug into the corner of the room wall. This plywood would be screwed through the drywall into the corner stud and the other stud. Use some good quality flat head wood screws of size #10x2.75", #10x3" or #12x2.75". Large screws like this will need a clearance hole drilled through the plywood. A pilot hole drilled into the studs will also permit easier installation and prevent the screws from splitting the studs. Four of these screws in each stud should be adequate. If you use a counter sink to bore a taper into the face side of plywood the flat head screws can draw in below the surface of the plywood. This will prevent them from interfering with the cabinet later.
Note that there is also access to the lower edge of the top plate inside the wall right along the corner with the ceiling. If you made the plywood tall enough to reach up to the ceiling you could also put some screws into the top plate too for more holding power.
Note that you should not place the plywood over any electrical boxes in such manner that the electrical box would become hidden. Another concern is that a laundry room is often near the the place where many electrical wires from the electrical panel fan out to other parts of the house in the walls and/or ceiling. For this reason do evaluate carefully so as to not be drilling or screwing into any electrical wires.
Once the plywood is in place you may want to finish it before mounting the cabinet. For raw wood make sure to use a good quality primer before applying the finish paint coats. You could also spackle over the countersunk screw heads so as to hide them and provide a nice flat appearance.
Mounting the cabinet will be a process of securing the back wall of the cabinet against the plywood. Most cabinets will already have holes in the back for just this purpose. If there are no holes then you will want to drill some. These holes should be the clearance size for the screws used to mount the cabinet. Appropriate screws (for a metal backed cabinet) are going to be round or pan head #12x1" wood screws. This size may penetrate the plywood and poke into the drywall some but that is OK. Slide the cabinet into place and mark the hole locations. Then drill pilot holes at those locations for the screws. Mount up the cabinet in place. I would recommend at least four screws if not six of them depending upon the size of the unit. Screws near the rear corners of the cabinet will be better than ones placed in the middle of the back. If there were existing holes that were too large for the heads of the screws you can select an appropriately sized flat washer to place under the screw heads.
Comment: Thanks Michael. Is it possible to just attach a 2x4 horizontally across the wall, screw that into two different studs, and then attach the mounting plate (or the server rack directly) to that 2x4? What screws would I use as to not have them poking through the back of the drywall into the wall space?
Comment: I would use the plywood. You could use horizontal 2x4s but you would need to use two of them otherwise the cabinet will either wobble or hang crooked. The 2x4s would also look crude and be what you would expect out in a out building or a shack.
Comment: Michael, I truly appreciate your help and getting back to me so quick. I attached an image to the original post to make what I am doing more clear and easier to understand what Im working with.  Red lines are studs, you can see that the builder used the one I was going to use for the leftmost cabinet. Yellow is how I was thinking of cutting a plywood sheet (would that still be strong enough to hold weight if the plywood is cut?), Orange is the 2x4 idea I had going. You can see the cabinet in the picture. It fits in the space with about 2-3 inches to spare. What would you do here? Thanks.
Comment: I see no reason to have the plywood extend over and under the cabinet. Screw it to the corner stud (which you neglected to show in your picture) and to the one stud to the right of the corner. Extend it to the ceiling and screw into the top plate.  I would carefully measure and just cut a square hole in the plywood to expose the existing patch panel. You want to keep the plywood in one piece instead of a bunch is small pieces as you have drawn.
Comment: Michael, That was my main question, Do I need the extra support of that third stud that the current white cabinets are using. The yellow drawings were meant to be one piece of ply cut to those specs, not different pieces of plywood. So you're tell me that I can mount it anywhere on the plywood, if the plywood sheet is mounted to the studs you mentioned from the top of the wall to the bottom of the white cabinet correct? I'm a little afraid of splitting the plywood attaching it at its edges to the corner stud and top plate, any tips for that? And use the round or pan head #12x1" wood screws?
Comment: The #12x1" screws can mount the cabinet to the plywood anywhere. I already provided info for screws to mount the plywood to the wall.
Comment: Michael's answer is fine. I'd add that mounting the cabinet is made easier if you screw a 2x4 to the plywood as a temporary shelf on which to rest the cabinet until all the cabinet's mounting screws are installed.


Why do Pillagers keep spawning near my singleplayer Minecraft house? Is there anything I can do about it?

Question: Usually while I'm in my Minecraft house, Pillagers keep spawning near my Minecraft house! Let me give you a little info on where I live, I live by the riverside, if you go along the right side of the lake, you'll reach a Village! But you can only see a bit of the Village from my Minecraft house if you set the render distance on maximum.
Comment: @fasterthanlight Not a duplicate because this is Java Edition and that is Bedrock Edition.
Comment: @pppery Oops, forgot to read the tags, retracting close vote.
Answer: From the wiki:

Patrols can spawn during the day on blocks with a block light level of 7 or lower. If a player is within two chunks of a village, patrols do not spawn.
The game picks a random location 24–48 blocks away from the player to try to spawn the patrol's captain.

Additionally, in bedrock there are additional location where Illager (patrols) can spawn, where other mobs cannot - this includes the river biome, but I am not certain how this works in Java.
You can check around the area where they normally spawn and see if there are any cave entrances nearby. Using F3 you can see the "light level" that a block has.
Answer: That's natural for Pillagers. They're meant to spawn randomly so you can get village bonuses and start raids. Light level means nothing in this scenario as they are an overworld mob. All they do naturally is come out and attack at random points, just like Wandering Traders spawn randomly. The best you could do is fight them off, but there is, sadly, no solution besides redstone traps.
EDIT:

Pillagers continually spawn in a 72×54×72 block volume centered on the top floor. They may spawn on any valid opaque block as long as the sky light level is 11 or lower, and the block light level is 8 or lower, but can also spawn on grass or sand blocks regardless of block light level.

Love, the official Minecraft Wiki. This disproves the light level theorum.
They spawn on all grass and sand, regardless of light level. Blocking it up with torches is not only a waste of materials, but ineffective as well. They will spawn in any of the 5184 blocks of dirt around your base. Place a crap-ton of netherrack or something around your base, but I doubt you could block the 5184 blocks you would have to place around your base you would need to prevent them from spawning. Just deal with it at this point. I would take pillager raids as awesome because they give you free stuff.
Comment: Light level does matter, place lots of torches around your base and you see that you never get attacked by pillagers. Pillagers only look at block light, they ignore skylight only
Comment: "Pillagers continually spawn in a 72×54×72 block volume centered on the top floor. They may spawn on any valid opaque block as long as the sky light level is 11 or lower, and the block light level is 8 or lower, **but can also spawn on grass or sand blocks regardless of block light level** ." Pillager - Minecraft Wiki. Screw it this is going in my answer.


Save mp4 video opencv

Question: I have mp4 video, and after drawing i need to save it.
I am trying to use
VideoWriter video("outcpp.avi", CV_FOURCC('M', 'J', 'P', 'G'), 10, Size(1280, 720));

But after saving this file is broken.
full code(i am using opencv 2.4.13):
#include <opencv2/opencv.hpp>
#include <iostream>
#include <fstream>
using namespace std;
using namespace cv;
Mat src;
void mouse_callback(int event, int x, int y, int, void*)
{
    if (event == EVENT_LBUTTONDOWN)
    {
        rectangle(src, Point(x, y), Point(x+10, y+10), Scalar(0, 255, 0));
        imshow("src", src);
    }
}

int main(void)
{
    CvCapture* cap = cvCreateFileCapture("1.mp4");
    VideoWriter video("outcpp.avi", CV_FOURCC('M', 'J', 'P', 'G'), 10, Size(1280, 720));
    while (1)
    {
        src = cvQueryFrame(cap);
        namedWindow("src", WINDOW_AUTOSIZE);
        imshow("src", src);
        setMouseCallback("src", mouse_callback);
        video.write(src);
        waitKey(0);
    }

    return 0;
}

Comment: When you say it is broken what does it mean ? How do you try to read it ? moreover, you don't need to call `setMouseCallback` on each frame, just create the "src" window with `namedWindow("src")` and set the mouse callback before entering the loop. One more remark : why are you recording the same frame as you're reading ? if you want to record the rectangle you draw, be sure this is not the case.
Comment: This code gives me error in ```src  = cvQueryFrame(cap)``` , whu you are not using ```videocapture()``` ? This api not c++ ? Please edit your question
Comment: @YunusTemurlenk i fotgot to say that it opencv 2.4.13
Comment: @antoine i am trying to open saved file, but it show me error, that file is damaged. You mean that i cant save video with rectangles using this?
Comment: This is not about the version. Your c++ tag is wrong you should edit question
Comment: @Maksim to save the image with rectangle you should write after waiting for user input. But again : how do you open the file ? did you try several player ? I guess your player can't read MPJG in MP4 container. You could try to open the saved video with your program directly to see if the file is OK or not.
Comment: @antoine oh, its realy stupid mistake:). Opencv cant read this file also, as i understand it happened because i try to use different interfaces.
Comment: could you post the `outcpp.mp4` file womewhere ? how big is it ?
Comment: you'll have to close the VideoWriter correctly in the end. To save  .mp4 you should use `VideoWriter video("outcpp.mp4", -1, 10, Size(1280, 720));`
Answer: Seams everything is working with VideoCapture. Why do you use C interface for reading and C++ for write?
I only move video.write after wait key to capture user clicks in video.
int main(void)
{
    vector<Rect> trafficLights;

    VideoCapture cap("/Users/alex/Documents/my_projects/hahaton_cams/kfu2.mp4");
    VideoWriter video("outcpp.avi", CV_FOURCC('M', 'J', 'P', 'G'), 10, Size(1280, 720));
    while (cap.read(src)) {
        namedWindow("src", WINDOW_AUTOSIZE);
        imshow("src", src);
        setMouseCallback("src", mouse_callback);

        if (waitKey(0) == 'q')
            break;
        video.write(src); // to capture user clicks
    }

    return 0;
}

OpenCV 4.2
Comment: Maybe you should add the reason of adding waitKey() before videowrite? Its cos of videowriter taking the previous frame before drawing.
Comment: > I only move `video.write` after wait key to capture user clicks in video.

Without it this code just write video without user clicks.
Comment: Okey your code is right. I just wanted you to add the reason as edit. The mistake is that but the reason: videowriter will take pure frame to write instead of proccessed frame in the question side.

Save mp4 video opencv


Two two-way switches in same gang box on same circuit. Only works when both are "On". What to do?

Question: I have 2 light switches in the same gang box, both connected to a ceiling light. They both appear to be 2-way switches as they both have "On/Off" printed on them. They do not work like 3-way switches, but appear to be 2-way connected in series. In order to toggle the light, one must be in the on position, and then the other can toggle the light normally. If either is in the "off" position, the light will be off, regardless of the other switch state.
What should I do? Do I remove one of the switches, and if so, do I just connect hot and neutral, and push gnd to the back of the box? What do I do with the empty space? Do I install an outlet to put in the extra gang just for the heck of it? Since they seem to be wired in series, I'm assuming this outlet will be tied to the switch?
I'm trying to figure out what the original intent was. It just occurred to me it could be intended for a ceiling fan, but replaced with a light-only fixture and then someone re-wired incorrectly? Is this possible?
Comment: Turn power off at the breaker. Remove the face plate. Unscrew the switches from the wall. Pull the switches out so you can see all the wiring. **DO NOT DISCONNECT ANYTHING**. Take clear, focused pics of the switches and the wiring going into the box. [Edit] those into your post. Carefully reassemble so you can turn the power back on until you get an answer.
Comment: Yes, your assumption about having been a light/fan control is entirely possible. As are about 100 other things. The key is what to do with it now. You certainly could replace 1 switch with outlets if that would make sense here, or you could get a cover plate that will simply cover the empty switch spot until you decide you need something else there. Don't do anything, though, until you get the pics. You'll get nicely detailed instructions once we get pics.
Comment: It sounds like the power comes into SW1 and from there gose to SW2 and than to the ceiling box. All the Neutrals should be twisted together. Photo's would decrease guessing/problems. Use a "double switch plate" that has a 'blank/switch' configuration.
Answer: This is quite common when someone changes a light switch in a 2 gang or 2 independent switch unit they get the feeder mixed up so only 1 switch has an always hot and they feed the switched hot to the 2nd switch.
A photo would make this easier but there is a wire that connects to both switches.
Move that wire on switch 1 to the other side and your problem will probably be resolved. It may be 2 wires under 1 side and 1 on the other maybe more but the hot needs to be moved, if light 1 is on all the time after that the wire to the fixture needs to be on the switched side of switch , if you provide a photo we could give you a better description,


22.04 upgrade on macbook hard disk disappeared

Question: I upgraded my working Ubuntu 21.10 to 22.04 (on my MacBookAir6,1), and upon rebooting the default kernel 5.15.0-25 ran for a few seconds, gave a bunch of DMAR faults, "gave up waiting for root file system device," and dropped out into busybox.  The dmesg notabily reported something like this
ata1.00: failed to IDENTIFY

The Ubuntu 21.10 (and versions before that going back 5 years) had worked fine on this machine.  The new 22.04 had thankfully left a 5.13.0-40 as an GRUB advanced boot option - and that boots normally and completely (and apparently can see/boot from the internal HD).  The dmesg from 5.13.0-40 had no DMAR faults nor ata1 failures.  The 5.13.0-40 dmesg showed successful discovery of internal hard disk
[1.188421] ata1: SATA max UDMA/133 abar m512@0xb0700000 port 0xb0700100 irq 53
[1.495830] ata1: SATA link up 6.0 Gbps (SStatus 133 SControl 300)
[1.497677] ata1.00: unexpected _GTF length (8)
[1.498794] ata1.00: ATA-8: APPLE SSD TS0128F, 109R0219, max UDMA/100
[1.499435] ata1.00: 236978176 sectors, multi 0: LBA48 NCQ (depth 32)
[1.500647] ata1.00: unexpected _GTF length (8)
[1.501444] ata1.00: configured for UDMA/100

I am also able to normally boot Ubuntu 22.04 from a USB disk (made with the rufus utility), with the strange situation that it also couldn't see the internal harddisk (from fdisk, gnome disk utility, or gparted).  It was able to see the USB disk it booted from.  Here are some excerpts from its 5.15.0-25 kernel dmesg
[1.449514] ata1: SATA max UDMA/133 abar m512@0xb0700000 port 0xb0700100 irq 54
[1.766097] ata1: SATA link up 6.0 Gbps (SStatus 133 SControl 300)
[1.766382] DMAR: DRHD: handling fault status reg 3
[1.766427] DMAR: [DMA Write NO_PASID] Request device [04:00.1] fault addr 0xfffe0000 [fault reason 0x02] Present bit in context entry is clear
[1.766525] ata1.00: failed to IDENTIFY (INIT_DEV_PARAMS failed, err_mask=0x80)

and later..
[ 7.032539] DMAR: DRHD: handling fault status reg 2
[ 7.032595] DMAR: [DMA Write NO_PASID] Request device [04:00.1] fault addr 0xfffe0000 [fault reason 0x02] Present bit in context entry is clear
[ 7.314168] ata1: SATA link up 6.0 Gbps (SStatus 133 SControl 300)
[ 7.314403] DMAR: DRHD: handling fault status reg 3
[ 7.314445] DMAR: [DMA Write NO_PASID] Request device [04:00.1] fault addr 0xfffe0000 [fault reason 0x02] Present bit in context entry is clear
[ 7.314533] ata1.00: failed to IDENTIFY (INIT_DEV_PARAMS failed, err_mask=0x80)
[ 7.314538] ata1: limiting SATA link speed to 3.0 Gbps
[12.408499] DMAR: DRHD: handling fault status reg 2
[12.408543] DMAR: [DMA Write NO_PASID] Request device [04:00.1] fault addr 0xfffe0000 [fault reason 0x02] Present bit in context entry is clear
[12.690278] ata1: SATA link up 3.0 Gbps (SStatus 123 SControl 320)
[12.690566] DMAR: DRHD: handling fault status reg 3
[12.690597] ata1.00: failed to IDENTIFY (INIT_DEV_PARAMS failed, err_mask=0x80)

I am not sure if the DMAR is related, as there are some additional DMAR entries in the new kernel
[0.269655] DMAR: No ATSR found
[0.269657] DMAR: No SATC found
[0.269660] DMAR: IOMMU feature pgsel_inv inconsistent
[0.269664] DMAR: IOMMU feature sc_support inconsistent
[0.269666] DMAR: IOMMU feature pass_through inconsistent
[0.269669] DMAR: dmar0: Using Queued invalidation
[0.269682] DMAR: dmar1: Using Queued invalidation

I am stuck..
Answer: After more detailed comparisons between dmesg of the kernel versions, it was apparent that pci device 04:00.1 was only referenced on the problematic kernel 5.15.0-25, where it had DMAR faults on device 04:00.1 (on MacBookAir6,1).  PCI device 04:00.0 shown by lspci is
04:00.0 SATA controller: Toshiba Corporation Device 010b (rev 14)

The problematic 04:00.1 - function number 1, of SATA controller, caused DMAR faults.  Search on DMAR fault addr and reason turned up an old discussion regarding the intel_iommu kernel option becoming ON by default for newer kernels.  This caused problems for some machines.  To fix it on MacBookAir6,1, the kernel option
intel_iommu=off

added to the GRUB config let my system boot up completely like before.
Comment: same bug reported by Matt - https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1970559
Comment: the 2017 archlinux thread on the intel_iommu issues - https://bbs.archlinux.org/viewtopic.php?pid=1741388#p1741388
Answer: Bill's answer solved my problem and saved me a lot of time. Thanks.
For a live USB system (e. g. for fresh installs), select the GRUB entry you want to boot (Install Ubuntu), press 'e' and add the temporary parameter 'intel_iommu=off' after the three dashes of the kernel line. Then press one of the boot keys. See this post for more details: https://askubuntu.com/a/19487
The parameter then got automatically applied in my installation and was inserted into /etc/default/grub which now has the entry
GRUB_CMDLINE_LINUX="intel_iommu=off"

Cheers, M.


CoreData crashing while reading the fetched object property from the same thread

Question: Below, I have 3 snippets of code related to CoreData fetching objects in different threads in different ways. One of these ways is crashing with EXC_BAD_INSTRUCTION when I am trying to read the data after fetching it from DB even though the fetching and reading is being done on the same thread.
print("hello: current thread is \(Thread.current)")
let moc = self.getChildMoc()
moc.performAndWait {
    let contacts = PPContactSyncHelper.contactsIfExistsWith(connectIds: connectIds, moc: moc)
    contacts.forEach { contact in
        print("hello: 2. current thread is \(Thread.current)")
        print("hello: \(contact.connectId)")
    }
}

DispatchQueue.main.async {
    let abContacts = PPContactSyncHelper.contactsIfExistsWith(connectIds: connectIds, moc: self.mainContext)
    abContacts.forEach { abContact in
        print("hello: \(abContact.connectId)")
    }
}

let contacts = PPContactSyncHelper.contactsIfExistsWith(connectIds: connectIds,
                                                                moc: moc)
contacts.forEach { contact in
    print("hello: 2. current thread is \(Thread.current)")
    print("hello: \(contact.connectId)")
}

The last snippet is the one that causes the issue while others can read the data successfully.
This is what I am doing.

I create a new child context with type privateQueueConcurrencyType and parent set as mainContext
I use this context first using performAndWait to fetch and read the data which works correctly.
I then try to fetch and read in main thread using mainContext. That also works.
When I try to fetch using the child context on the same thread and read without perform block, there it crashes even though I am on the same thread.

The function PPContactSyncHelper.contactsIfExistsWith fetches the data from coredata inside the performAndWait block using the context provided.
What am I missing here?
Answer: With managed object contexts, you always need to use perform or performAndWait. Except for one situation: If you're using a main queue managed object context and you are running on the main queue, you can skip those methods.
In your examples:

Example 1 works because you used performAndWait. It's a private queue (not main queue) context, and you used it correctly.
Example 2 works because it's a main queue context and you used DispatchQueue.main.async. This is the one exception I mentioned above, so you're OK where.
Example 3 doesn't work because you're using a private queue context but you didn't use perform or performAndWait. You need to use one of those here to avoid crashing. You're on the same thread as example 1, but that doesn't matter. What's important is whether your Core Data code runs on the context's queue.
Answer: The understanding of how NSManagedObjectContext is created and which thread it is associated with is incorrect. When a NSManagedObjectContext is created on a particular thread using initWithConcurrencyType that does not mean that particular thread is NSManagedObjectContext's thread. It is just created on that thread and nothing else. Only when we call perform or performAndWait on NSManagedObjectContext, the block that we pass is run on the NSManagedObjectContext's thread. The results depict the same scenario.
However, if the NSManagedObjectContext is created with init only without concurrency type then current thread would be NSManagedObjectContext's thread.


Classification of $O(2)$-bundles in terms of characteristic classes.

Question: It is well-known that $SO(2)$-principal bundles over a manifold $M$ are topologically characterized by their first Chern class. I was wondering what was the characterization of $O(2)$-bundles in terms of characteristic classes. I guess the first and second Setiefel-Whitney classes are necessary for the topological characterization of $O(2)$-bundles, but they can't be enough, because if $w_{1} = 0$ then one should recover the classification of $SO(2)$-bundles, which is given by the first Chern class and not by the second Stiefel-Whitney class.
Thanks.
Comment: @Dylan: $E \otimes \det(E)$ need not be orientable when $E$ is even-dimensional.
Comment: I'm confused... it seems like an unoriented bundle $E$ is the same as the knowledge of (1) $\text{det}(E)$ and (2) $E \otimes \text{det}(E)$ (or maybe duals thereof, etc.) In other words, an oriented rank 2 bundle is the same as line bundle and an oriented rank 2 bundle with the correspondence given by $(V, L) \mapsto V \otimes L^{-1}$. I think that's what Chanler's answer is saying, but it feels like there's a contradiction with what Mike is saying... what's going on?
Comment: Unfortunately characteristic classes are not enough to completely determine $O(2)$-bundles. You only have $p_1$, $w_1$, and $w_2$, and these aren't enough to classify rank 2 bundles over $S^2$, even!
Comment: (I guess one possibility is that this correspondence is surjective but not bijective.)
Comment: The Cech cocycle corresponding to the $O(2)$-bundle defines an element $w_{1}\in H^{1}(M,\mathbb{Z}_{2})$ together with an element $w_{2}\in H^{2}(M,\mathbb{Z}_{2})$. They look like the first and second Stiefel-Whitney classes of the $O(2)$ bundle. However, I don't see the implication in the other direction.
Comment: Aha! Thank you @OscarRandal-Williams!
Answer: We have a fiber sequeunce $BSO(2)\to BO(2)\to B\mathbb{Z}/(2)$, and so we have that a $O(2)$-bundle, or a map $X\to BO(2)$ factors $X\to BSO(2)$ if and only if the composite $X\to B\mathbb{Z}/(2)$ is null-homotopic. $Hom_{\mathcal{h}Top}(X, B\mathbb{Z}/(2))=H^1(X; \mathbb{Z}/(2))$, so we have a class $x\in H^1(X; \mathbb{Z}/(2))$ representing the isomorphism class of the bundle. This class is clearly the pullback of the the universal class $x\in H^1(BO(2); \mathbb{Z}/(2))=(\mathbb{Z}/(2)[w_1, w_2])_{deg=1}=\mathbb{Z}/(2)w_1$. We note that since $O(2)\neq SO(2)\times \mathbb{Z}/(2)$, this class cannot vanish identically, so that $x=w_1$. Now we are left with an $SO(2)$-bundle, which you already know about!
Comment: Thanks for the nice answer. This means that a $O(2)$-bundles is completely characterized by its first Stiefel-Whitney class and a class in $H^{2}(M,\mathbb{Z})$? In other words, an element of $H^{1}(M,\mathbb{Z}_{2})$ together with an element of $H^{2}(M,\mathbb{Z})$ defines a unique $O(2)$-bundle?


How do I delete items from a dictionary while iterating over it?

Question: Can I delete items from a dictionary in Python while iterating over it?
I want to remove elements that don't meet a certain condition from the dictionary, instead of creating an entirely new dictionary. Is the following a good solution, or are there better ways?
for k, v in mydict.items():
    if k == val:
        del mydict[k]

Comment: A related question with very interesting answers: http://stackoverflow.com/questions/9023078/custom-dict-that-allows-delete-during-iteration.
Comment: Dumb observation: Your whole loop is kind of pointless if you're just looking for a specific key. You could replace it with `try: del mydict[val]` `except KeyError: pass` or as a one-liner, with `mydict.pop(val, None)`, both of which would be `O(1)` operations, not `O(n)`. The question is still valid if the condition for deletion is more than just "equal to some value" though.
Comment: Many of the comments & answers here presume that this is impossible by definition - but it's not, it's just that Python doesn't provide an implementation.  For example in Java, it's possible to delete the most-recently iterated value of a `HashMap`  by using the iterator's `remove()` method.  This is highly desirable, because as all the examples here show, working around it is annoying, error-prone, and a waste of memory and time.
Answer: For Python 3+:
>>> mydict
{'four': 4, 'three': 3, 'one': 1}

>>> for k in list(mydict.keys()):
...     if mydict[k] == 3:
...         del mydict[k]

>>> mydict
{'four': 4, 'one': 1}

The other answers work fine with Python 2 but raise a RuntimeError for Python 3:

RuntimeError: dictionary changed size during iteration.

This happens because mydict.keys() returns an iterator not a list.
As pointed out in comments simply convert mydict.keys() to a list by list(mydict.keys()) and it should work.

For Python 2:
A simple test in the console shows you cannot modify a dictionary while iterating over it:
>>> mydict = {'one': 1, 'two': 2, 'three': 3, 'four': 4}

>>> for k, v in mydict.iteritems():
...    if k == 'two':
...        del mydict[k]

------------------------------------------------------------
Traceback (most recent call last):
  File "<ipython console>", line 1, in <module>
RuntimeError: dictionary changed size during iteration

As stated in delnan's answer, deleting entries causes problems when the iterator tries to move onto the next entry. Instead, use the keys() method to get a list of the keys and work with that:
>>> for k in mydict.keys():
...    if k == 'two':
...        del mydict[k]

>>> mydict
{'four': 4, 'three': 3, 'one': 1}

If you need to delete based on the items value, use the items() method instead:
>>> for k, v in mydict.items():
...     if v == 3:
...         del mydict[k]

>>> mydict
{'four': 4, 'one': 1}

Comment: To elaborate on @max's elaboration, it will work if you convert the above code with 2to3.  One of the default fixers will make the loop look like `for k, v in list(mydict.items()):` which works fine in Python 3.  Same for `keys()` becoming `list(keys())`.
Comment: @TomášZato as Walter pointed out, for python3 you need to use `for k in list(mydict.keys()):`  as python3 makes the keys() method an iterator, and also disallows deleting dict items during iteration.  By adding a list() call you turn the keys() iterator into a list.  So when you are in the body of the for loop you are no longer iterating over the dictionary itself.
Comment: I would opt for `for key, value in my_dict.copy().items():` so you are iterating through a duplicate dictionary and deleting from the original. It maintains the cleanliness of the data typing
Comment: can make it shorter `for k in list(mydict):`
Comment: Will `list` make a copy of the keys, or only point at each of them?
Comment: @matanster `list` basically converts an `iterator` into a list of `keys`.
Comment: https://stackoverflow.com/questions/6777485/modifying-a-python-dict-while-iterating-over-it
If the runtime error is removed there will a chance that you won't be able to iterate over all items
Comment: @xle You should make an answer out of your comment. It indeed seems to be cleaner.
Answer: You could also do it in two steps:
remove = [k for k in mydict if k == val]
for k in remove: del mydict[k]

My favorite approach is usually to just make a new dict:
# Python 2.7 and 3.x
mydict = { k:v for k,v in mydict.items() if k!=val }
# before Python 2.7
mydict = dict((k,v) for k,v in mydict.iteritems() if k!=val)

Comment: @senderle: Since 2.7 actually.
Comment: The dict comprehension approach makes a copy of the dictionary; luckily the values at least don't get deep-copied, just linked. Still if you have a lot of keys, it could be bad. For that reason, I like the `remove` loop approach more.
Comment: You can also combine the steps: `for k in [k for k in mydict if k == val]: del mydict[k]`
Comment: the first solution is the only efficient one on big dicts in this thread so far - as it doesn't make a full length copy.
Answer: Iterate over a copy instead, such as the one returned by items():
for k, v in list(mydict.items()):

Comment: Under Python 3, `dict.items()` returns an iterator rather than a copy. See commentary for [Blair](https://stackoverflow.com/users/668807/blair)'s [answer](https://stackoverflow.com/a/5385075/2809027), which (sadly) also assumes Python 2 semantics.
Comment: That doesn't make much sense -- then you can't `del v` directly, so you've made a copy of each v which you're never going to use and you have to access the items by key anyways. `dict.keys()` is a better choice.
Comment: @Josh: It all depends on how much you're going to need to use `v` as a criterion for deletion.
Comment: Per python 3.11 this is the most correct answer but how can it bubble to the top.
Answer: You can't modify a collection while iterating it. That way lies madness - most notably, if you were allowed to delete and deleted the current item, the iterator would have to move on (+1) and the next call to next would take you beyond that (+2), so you'd end up skipping one element (the one right behind the one you deleted). You have two options:

Copy all keys (or values, or both, depending on what you need), then iterate over those. You can use .keys() et al for this (in Python 3, pass the resulting iterator to list). Could be highly wasteful space-wise though.
Iterate over mydict as usual, saving the keys to delete in a seperate collection to_delete. When you're done iterating mydict, delete all items in to_delete from mydict. Saves some (depending on how many keys are deleted and how many stay) space over the first approach, but also requires a few more lines.
Comment: @Nils It doesn't throw an exception but it's still incorrect. Observe: http://codepad.org/Yz7rjDVT -- see e.g. http://stackoverflow.com/q/6260089/395760 for an explanation
Comment: `You can't modify a collection while iterating it.` this is just correct for dicts and friends, but you can modify lists during iteration: `L = [1,2,None,4,5] <\n> for n,x in enumerate(L): <\n\t> if x is None: del L[n]`
Comment: Got me here. Still `can't` is correct only for dict and friends, while it should be `shouldn't` for lists.
Answer: You can use a dictionary comprehension.
d = {k:d[k] for k in d if d[k] != val}
Comment: But it creates a new dictionary instead of modifying `d` in place.
Comment: This is the most Pythonic.
Answer: With python3, iterate on dic.keys() will raise the dictionary size error. You can use this alternative way:
Tested with python3, it works fine and the Error "dictionary changed size during iteration" is not raised:
my_dic = { 1:10, 2:20, 3:30 }
# Is important here to cast because ".keys()" method returns a dict_keys object.
key_list = list( my_dic.keys() )

# Iterate on the list:
for k in key_list:
    print(key_list)
    print(my_dic)
    del( my_dic[k] )

print( my_dic )
# {}

Answer: It's cleanest to use list(mydict):
>>> mydict = {'one': 1, 'two': 2, 'three': 3, 'four': 4}
>>> for k in list(mydict):
...     if k == 'three':
...         del mydict[k]
...
>>> mydict
{'four': 4, 'two': 2, 'one': 1}

This corresponds to a parallel structure for lists:
>>> mylist = ['one', 'two', 'three', 'four']
>>> for k in list(mylist):                            # or mylist[:]
...     if k == 'three':
...         mylist.remove(k)
...
>>> mylist
['one', 'two', 'four']

Both work in python2 and python3.
Comment: This isn't good in case your dataset is large. This is copying all the objects in memory, right?
Comment: @AFP_555 Yes - my goal here is for clean, parallel, pythonic code. If you need memory efficiency, the best approach I know of is to iterate and build either a list of keys to delete or a new dict of items to save. Beauty is my priority with Python; for large datasets I am using Go or Rust.
Answer: You could first build a list of keys to delete, and then iterate over that list deleting them.
dict = {'one' : 1, 'two' : 2, 'three' : 3, 'four' : 4}
delete = []
for k,v in dict.items():
    if v%2 == 1:
        delete.append(k)
for i in delete:
    del dict[i]

Comment: Its rather a duplicate of @Ritzel's 1st solution (efficient on big dicts w/o full copy). Though a "long read" w/o list comprehension. Yet is it possibly faster nevertheless ?
Answer: There is a way that may be suitable if the items you want to delete are always at the "beginning" of the dict iteration
while mydict:
    key, value = next(iter(mydict.items()))
    if should_delete(key, value):
       del mydict[key]
    else:
       break

The "beginning" is only guaranteed to be consistent for certain Python versions/implementations. For example from What's New In Python 3.7

the insertion-order preservation nature of dict objects has been declared to be an official part of the Python language spec.

This way avoids a copy of the dict that a lot of the other answers suggest, at least in Python 3.
Answer: I tried the above solutions in Python3 but this one seems to be the only one working for me when storing objects in a dict. Basically you make a copy of your dict() and iterate over that while deleting the entries in your original dictionary.
        tmpDict = realDict.copy()
        for key, value in tmpDict.items():
            if value:
                del(realDict[key])

Comment: Can also use `for key, value in my_dict.copy().items():` to be more succinct and avoid adding more variables to your scope than necessary
Answer: One-liner:
my_dict = {k: v for k, v in my_dict.copy().items() if not k == value}

The my_dict.copy() object is used for the iteration only and will not be available outside the scope of the dictionary comprehension. This avoids editing the object over which you are currently iterating, as advised against by @user395760 in their answer.
You can split this over multiple lines for clarity:
my_dict = {
    k: v
    for k, v in my_dict.copy().items()
    if not k == value
}

Answer: Another nice and efficient way using partial function
next((partial(d.pop, k) for k in d if k == v), partial(print, f"{v} key not found"))()

Comment: But hard to read and understand.


How do I adjust a Delta bathroom faucet that has a scald guard?

Question: I have a new Delta faucet but the water temperature is too low. The handle actually doesn't even turn all the way to "hot", there's something preventing it from turning the entire way.
Is there a way to adjust the faucet so I can get hotter water?
Answer: This is a feature of the faucet called "scald guard" that you can set to prevent overly hot water from burning people. I have a new construction and I found that the default setting was a bit overkill, so I adjusted it.
You only need a small hex key (size?) to adjust the scald guard. Before you begin make sure you close the bathtub drain or put something over the shower drain, the screw is very small!
There's a tiny screw at the bottom of the faucet:

Unscrew this and then remove the handle, you should see the plastic assembly. Take note of the circular piece, you need to slide this off in order to adjust the faucet:

Now you're ready to adjust it. Note the triangular plastic bit that is at the "4 oclock" position. As noted on the plastic part itself, turning it counter clockwise let's the handle turn more towards hot, and clockwise turns it colder. The circle thing is in there with saw teeth, so you just can't turn it, you need to pull it out, turn it, and then push it back in. I moved mine to be closer to the "2 oclock" position:

Now you can slip the circular plastic piece back on, then the handle, and then the small hex screw again to finish it off (basically go in reverse order). Your faucet should now be able to turn to the hotter position.
Adjust to your liking; also be cognizant of safety, the thing is there for a reason, and the plastic bit will prevent you from adjusting it too far towards hot. My personal set up is a little bit hotter for our master shower and bath, but not as much in our guest bathroom since there might be kids, etc.
Comment: FWIW, the versions I saw in the UK recently had a safety stop, but also had a button that could be pushed in to override that stop. Nice compromise for adults; kids are probably better served by not having the override.


heroku open - no app specified

Question: I've just created a simple Rails app using
rails new myapp

then created the heroku stack using:
heroku create --stack cedar

But when I try opening the app on Heroku using:
heroku open

I get:
 !    No app specified.
 !    Run this command from an app folder or specify which app to use with --app <app name>

And this:
$ heroku open --app myapp

gives me this:
 !    App not found

Am I missing something obvious?
Comment: You no longer have to specify the cedar stack, it is the default now
Comment: Make sure to scroll down past the first couple answers. [This one](http://stackoverflow.com/a/24816347/199712) is the best.
Answer: If you have an existing app on Heroku and you are getting this no app specified message, you can correct it by running this on your local terminal:
heroku git:remote -a MyHerokuAppName
Comment: This is exactly what I needed.

I use auto-deploys from a git branch. For an unrelated reason I needed to form a new repo. This was exactly what I needed to fix that.

Also, when I wanted to interact with heroku from a different machine (actually a cloud9 dev environment), this simple command let me connect and work with heroku.
Answer: Heroku by default is not creating app with your directory name, so when you do
heroku create --stack cedar
Creating calm-bayou-3229... done, stack is cedar
http://calm-bayou-3229.herokuapp.com/ | firstname.lastname@example.com:calm-bayou-3229.git

it is creating application named 'calm-bayou-3229'
And you can do
heroku open --app calm-bayou-3229
Opening http://calm-bayou-3229.herokuapp.com/

You can always list your apps with:
heroku apps

Answer: Another approach to solving the issue is to take a broad understanding of what the .git/config file associated with the heroku app is doing and make the necessary tweaks.
1.Open .git/config from your heroku project's root.
Your git config file may look something like this, especially if you are juggling a couple heroku accounts on your machine.
git@heroku.{heroku.account} shows up instead of email@example.com because of the configuration in your ~/.ssh/config file.  The reference to heroku-app-8396.git should be updated to match your heroku project name. Each heroku account you have should have an entry in the ~/.ssh/config file.  Obviously, the heroku account that this heroku project is associated with should show up in your .git/config file.
[core]
    repositoryformatversion = 0
    filemode = true
    bare = false
    logallrefupdates = true
    ignorecase = true
    precomposeunicode = false
[remote "origin"]
    fetch = +refs/heads/*:refs/remotes/origin/*
    url = email@example.com:heroku-app-8396.git
[remote "heroku"]
    fetch = +refs/heads/*:refs/remotes/heroku/*
    url = email@example.com:heroku-app-8396.git
[branch "master"]
    remote = origin
    merge = refs/heads/master
[heroku]
  account = heroku.account

2.When I run git pull heroku master, all seems to run well.
3.When I run heroku logs, I get an error message:
$ heroku ps
!    No app specified.
!    Run this command from an app folder or specify which app to use with --app APP.

Why?
As far as I can tell, the heroku command doesn't seem to know what to do with the {heroku.account} references.  If we change those references to com (which is the default value when you are not using the 'accounts' heroku plugin), the heroku commands work once again, but now our git calls are saying there is a different problem:
$ git pull heroku master

 !  Your key with fingerprint d6:1b:4c:48:8c:52:d4:d6:f8:32:aa:1a:e7:0e:a2:a1 is not authorized to access smooth-robot-8396.

fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

One way to resolve this is to define a remote for git and a remote for heroku and then tell heroku which remote to use.
[core]
    repositoryformatversion = 0
    filemode = true
    bare = false
    logallrefupdates = true
    ignorecase = true
    precomposeunicode = false
[remote "origin"]
    fetch = +refs/heads/*:refs/remotes/origin/*
    url = email@example.com:heroku-app-8396.git
[remote "heroku"]
    fetch = +refs/heads/*:refs/remotes/heroku/*
    url = firstname.lastname@example.com:heroku-app-8396.git
[remote "heroku-app"]
    fetch = +refs/heads/*:refs/remotes/heroku/*
    url = firstname.lastname@example.com:heroku-app-8396.git
[branch "master"]
    remote = origin
    merge = refs/heads/master
[heroku]
    remote = heroku-app
    account = heroku.account

I like to explicitly specify the remote when I'm pushing content to a remote, so the heroku remote is for that, even though this configuration also accommodates pushing/pulling using the default (e.g., git push).  I create a new remote 'heroku-app' and add remote = heroku-app to tell heroku to use a remote that doesn't include the heroku account in the URI.
Now I can run my git and heroku commands as I want to.
Comment: Could you provide an example of your ~/.ssh/config? Also an example of how you push to heroku would be helpful. I tried following your example but was unable to resolve the issue.
Comment: Thank you, sir! This is an amazing answer!
Answer: I had the same issue, All I had to do was cd to project dir instead of running commands from model folder in the project dir.
Answer:
This crazy thing worked for me:

If you have the app's git repo copy on you local machine then cd to that location and that's it!!
You will be able to use the app. You can verify this by commands like: heroku logs -n 1500

heroku open - no app specified


Django ModelForm - Create instance with foreign key

Question: I'm wondering what the correct way to create a model instance with a django model form is when it contains a required FK?  I think it may have to do with the exclude class property, but in the view I am trying override this before save.
Model:
 class Profile(models.Model):
    client = models.OneToOneField('auth.User')
    first_name = models.TextField(blank=True,)
...

Form:
class ProfileForm(floppyforms.ModelForm):
    class Meta:
        exclude = ('client',)
        model = Profile

        widgets = {
            'first_name': floppyforms.TextInput(attrs={'placeholder': 'First Name'}),
...

View:
def post(self, request):
    form = ProfileForm(request.POST)
    if form.is_valid():
        form.save(commit=False)
        form.client = User.objects.create(username=request.POST['email'],)
        form.save()
        return redirect('/success')
    return redirect('/error')

The error:
django.db.models.fields.related.RelatedObjectDoesNotExist: Profile has no client.

Looking at the Admin, I can see that the user has been created however.

Cheers
Answer: You have an error in your views.py. It should be:
def post(self, request):
    form = ProfileForm(request.POST)
    if form.is_valid():
        new_profile = form.save(commit=False)
        new_profile.client = User.objects.create(username=request.POST['email'],)
        new_profile.save()
        return redirect('/success')
    return redirect('/error')

You shouldn't assign the client to your form, but to the in-memory instance new_profile, then call new_profile.save() to save the new_profile to the database.
Comment: Doh.  Thanks for this.


Need smallest possible images for iPad that can zoom to 200% without losing quality

Question: right now I'm using 2048x1546 images at 132dpi, PNG files. they look amazing but they are huge in file size.
any tips on how to get around having such large images in both dimensions and file size? (mostly file size i'm worried about here...)
Comment: Without any examples on the kinds of images, it's hard to suggest fitting solutions - technical or not.
Comment: You'll get more and possibly better answers on StackOverflow, which is more of a technical Q&A site than here.
Comment: @Charles It's not a programming question, so I don't think it really belongs on Stack Overflow. Of all of the Stack Exchange sites, I can't think of one where it's a perfect fit. I'm going to leave it alone for now.
Comment: @Patrick - Exactly how is this not a programming question? He's looking for tips on how to zoom images on the iPad without sacrificing quality. Definitely a programming question. And just look at the answers - they're all programming (or at least technical) solutions.
Comment: And so what if it is a programming questions? It's still UI related. UI takes programming.
Comment: @DA01 - Please read the FAQ - it explicitly states that programming questions should NOT be asked here.
Comment: @DA01 - Also, UI does not always take programming. How much programming is involved in the doorknob on your front door?
Answer: The iPad screen is 1024-by-768 so to view images at 200% zoom with no pixelation you are going to need an image that's 2048 x 1546.
Possible solutions:

Find or write an image viewer that does interpolation between the pixels for the higher zoom values. The images won't be pixelated, but it will be blurred.
Increase the compression of the images. This will reduced the space they take up on the "drive", but they still need to be uncompressed for display.
Accept some pixelation at the highest zoom factors and choose a smaller image size.
Have several versions of the image for different resolutions and break the higher resolution image into chunks and only display the bits that can be seen. This is what happens with Deep Zoom type technologies as @Anders points out in his answer.

You have to balance the quality you get from the large image against the amount of memory it uses and find a compromise that's acceptable.
iPad specs
Comment: @miles - if you have 1024 x 788 *pixels* to fill you need an image that's 1024 x 768 *pixels* in dimension. How you got that image is not relevant to this discussion. You need to know when scanning and printing.
Comment: Or displaying at actual size on a monitor which is **not** what this question is about.
Answer: You could probably use Seadragon Ajax - it's the javascript implementation of Silverlights DeepZoom.
See the answer on Get Satisfaction for Seadragon Ajax
Answer: Do you have to use PNG files? JPGs can be compressed quite a bit more if these are photographic in nature.
Answer: I don't know how you can reduce the image dimensions but reducing the file size of PNG images is easy:

Reduce number of colors - this will have the biggest affect but might , depending on the image, also have a similar big impact on image quality (for an example open the image in your favorite image editor, run the posterize effect and save).
Drop unnecessary information and improve compression - there are a lot of programs that do that, from my experiments PNGOUT is the most effective, this will not effect the image quality.

There are a lot of other things you can do but from my experience those two are where you will get major improvements for little work.
Also, you should know those will reduce the file size, this does not mean they will reduce the amount of memory needed to display the image (in most cases they won't)


Scheduled sms android development

Question: I'm new to the android app development world and looking for a tutorial on scheduling sms to be sent at set times. Or some sample code that anyone has.
Thanks
Answer: I think AlarmManager can help you. You can find basic example here
Comment: Thanks, I think that's going to  do what I need.

Scheduled sms android development


How does ionic.config.js in ionic2 work

Question: I need to know in detail, how does the ionic.config.js file (in ionic2) work.
Can I use Grunt instead of ionic.config.js ?
Answer: Yes you can use Grunt or Gulp for automating your builds.
Regarding your first question: Can you give us more details? Maybe tell us a bit more about what you are trying to achieve with the config file, or give us an overview of what tasks you want to accomplish?

How does ionic.config.js in ionic2 work


Use XBMC portable

Question: I would like to use XBMC in Ubuntu without installing it (portable). Under Windows it can be done. I tried many things in Ubuntu, but none of them worked.
I am using Ubuntu 13.10 x64.
THX. XBMCuser
Answer: Portable installations of applications isn't something that is usually done under Linux. The main reason being is dependencies. In Windows most programmes ship with every library you need for that programme. As such you will generally have multiple versions of the same library under Windows.
Under Linux the library is installed once through the package manager and that library would be listed as a dependency. Many different applications will then use that same version of the library. To get a portable version you would need to make sure that each host contains all the dependencies required or to have all the dependencies on the USB stick as well. This is, of course, not a very good option.
Instead, what I personally suggest, is that you get a Live USB that has support for persistent storage. This means that any changes you make will be saved. In the Live USB you would then be able to install XBMC and boot up the Live USB on any PC that you require to have XBMC on. For maximum compatibility may I suggest installing a 32-bit version of the operating system instead? This should work on nearly any computer that you require it to then. Ubuntu has support for persistent storage and the USB can be easily made from Ubuntu. The following link should help you get it set up.
http://www.ubuntu.com/download/desktop/create-a-usb-stick-on-ubuntu
EDIT: Depending on how the live USB is set up (if a full install to the USB stick was done this is definitely possible)  you could chroot into the USB and then use the host system to run the version of XBMC that is on the USB version of a Linux distribution. For more on this you should research how a chroot works.
Comment: Thx i tried and it run´s great.

Use XBMC portable


Example of a recursively enumerable set as a limit of recursive sets

Question: I am reading Soare's book and I am trying to understand the following statement:
A function f has r.e. degree iff it is the limit of a recursive sequence ${f_{s}}_{s \in \mathbb{N}}$ and its modulus of convergence $m \leq_{T}f$.
However, I am trying to find an example to illustrate this theorem. Is it useful to identify the difference between recursive sets and r.e. set?
Answer: Sure! The classic example of this is the characteristic function of the Halting Problem, which is recursively enumerable but not recursive.
This function, $f$, is defined as: $f(x)=1$ if $\varphi_x(x)$ halts, and $f(x)=0$ otherwise (where $\{\varphi_e: e\in\mathbb{N}\}$ is some standard enumeration of the partial computable functions).
Now $f$ is a limit of recursive functions in a natural way. Let $f_s(x)=1$ if $\varphi_x(x)$ halts in at most $s$ stages, and $f_s(x)=0$ otherwise. Then each $f_s$ is recursive, and their limit is $f$: $f(x)=1$ iff for all sufficiently large $s$, we have $f_s(x)=1$.  So the quoted result says that $f$ has r.e. degree (and indeed, $f$ itself is r.e.).
So this is an example of a function with r.e. degree being the limit of a sequence of recursive functions. In general, though, such an $f$ need only have $\Delta^0_2$ degree! (This is Shoenfield's Limit Lemma.) And there are lots of $\Delta^0_2$ degrees which are not r.e. degrees. In order to ensure that the limit of a sequence of recursive functions is of r.e. degree, we need to add a technical condition; this is the requirement that the modulus of convergence (that is, at what point $t=m(n)$ we see $f(n)$ "stabilize" - $f_s(n)=f(n)$ for all $s>t$) be "simple". And indeed, it's easy to see that in the example above, the modulus of convergence of $f$ is indeed $\le_Tf$.
Comment: Thanks Noah, it is a great example. My second part of the question is more related to the following: is this theorem helpful to show negative Answers? For example, I am trying to proof the following: if E is an equivalence relation r.e. which is not recursive, then for each n there are infinitely many classes whose size is different than n. Is there any way to use the limit lemma to show that something is not recursive?
Comment: @user350168 No, the limit lemma (and similar results) are used to provide an *upper* bound on complexity (if we know $f$ is the limit of an appropriate sequence of functions, then $f$ isn't "too complicated") or, in the other direction, to get "representations" of functions we know to be simple (e.g. going from a $\Delta^0_2$ function to a representation of it as a limit of functions). But recursive functions are *already* as simple as can be, and *trivially* have nice representations (e.g. $f$ is the limit of itself :P). So these results aren't really useful for providing *lower* bounds.
Comment: Oh I see! Thank you very much, I learned a lot with this!


Why did the second coat of my hardwood floor finish blister?

Question: I refinished a 100 yr old wood floor. Both coats were oil based poly. Temperature was relatively consistent, zero moisture. It was cleaned before coating.
First coat was given a full 24 hours to dry before the second coat. The blistering wasn't consistent across the floor. Parts of the floor look great, other parts are not.I can't figure out what went wrong.
Comment: Did you sand between the coats?
Comment: I agree with stevesh but I will use steel wool just enough to scratch or buff the surface.
Comment: maybe temperature was consistent, but was it within the allowable range?
Comment: I suggest you take a look through the finishing questions at the [woodworking.se] sister site. _Loads_ of info there about finishing and refinishing.
Answer: Humidity or thickness or wasn't dry in some spots… Or perhaps the re-coat time was 4 to 6 hours not 24…
But looks like you need to sand it back and redo it.


docker call program (nodejs) from another container (supervisor)

Question: My docker-compose.yml is like:
nodejs:
  build: .
  dockerfile: Dockerfile-nodejs
  tty: true
  ports:
    - "${SOCKET_PORT}:8081"
  volumes:
    - ../node:/var/www/html

supervisor:
  build: .
  dockerfile: Dockerfile-supervisor
  tty: true
  volumes:
    - ..:/var/www/html
    - ./config/supervisor/conf.d:/etc/supervisor/conf.d
  links:
    - nodejs:nodejs

And I've created supervisor program config file:
[program:nodejs.socket]
command=nodejs /var/www/html/node/server.js
autostart=true

But: I can't run this program, because supervisor's container

can't find command 'nodejs'

Question: Can I actually run nodejs from supervisor-container or I must install supervisor in nodejs-container?
Comment: Isn't the command node?
Comment: By default it is `node`, but I've renamed it in docker-compose.yml file.
Anyway it doesn't work too.
Answer:
Question: Can I actually run nodejs from supervisor-container or I must install supervisor in nodejs-container?

You must install supervisor in the image that holds nodejs, because supervisor needs to execute nodejs that means to have it as child process.
That is the common way. However, you can share the pid namespace between two containers, but you will need to have nodejs installed in the same image too. So at that point, that is becoming tricky.
Comment: Ok, got it. Thanks.


nvd3 tooltip is showing index instead of label

Question: I am having problem nvd3 tooltip in multichart(multilinechart). Here my XAxis label are JAN,FEB,MAR... DEC. But when i mouse over in the graph it is showing 0,1,2,3.. 11 as tooltip title. But i need to show JAN,FEB.. DECinstead of index. Here is my chart option code,
{
  "chart": {
    "type": "multiChart",
    "height": 400,
    "interpolate": "linear",
    "showLegend": false,
    "margin": {
      "top": 50,
      "right": 100,
      "bottom": 60,
      "left": 100
    },
    "reduceXTicks": false,
    "useVoronoi": false,
    "useInteractiveGuideline": true,
    "duration": 500,
    "xAxis": {
      "axisLabel": "MONTHLY",
      "tickPadding": 10,
      "tickSize": 1,
      "tickValues": [
        0,
        1,
        2,
        3,
        4,
        5,
        6
      ]
    },
    "yAxis1": {
      "axisLabel": "Left",
      "tickPadding": 10
    },
    "yAxis2": {
      "axisLabel": "Right",
      "width": 60,
      "tickPadding": 10
    },
    "yDomain1": [
      0,
      5
    ],
    "yDomain2": [
      0,
      100
    ]
  }
}

Here is the issue in image (Need to show FEB but it is showing 1),

Here is second(Need to show MAR but it is showing 2)

Please some one help to identify the issue,
Thanks in Advance.
Comment: Can you please create a jsfiddle with testdata?
Answer: You can try to use a method interactiveLayer.tooltip.headerFormatter to edit header's label, like:
chart.interactiveLayer.tooltip.headerFormatter(d => {
      if (typeof d === 'string') return d
    })


Post to page wall from my website (with "Hide from News Feed")

Question: It's possible to manually add a post to my wall for past and check "Hide from News Feed", but is there any way to post to my wall with "Hide from News Feed" option from my website with PHP?
Answer: By looking at the Graph API documentation, you can see that there is no such option for a Post. Moreover, if you retrieve a news feed from the Graph API, posts that were hidden are not present in the returned json. You can try it by querying the Grap API about your news feed, hide a post and query it again. If you compare the two jsons you will see that the hidden post is just not present in the second. So I would say that it is not possible.


Getting simple Javascript / jQuery to work (ScrollTo by Ariel Flesler)

Question: UPDATE: Outstanding mr. tpaksu solved my problems and you can see the horizontal ScrollTo in action @ www.visioville.fi/en/
I had my time fiddling around with CSS, but i came to conclusion that this is pretty much the only thing i cannot get done without Javascript / jQuery.
I've been trying to implement Goro's suggested jQuery.ScrollTo by Ariel Flesler, but i can't seem to get it working in any way. Add to the fact that i'm a total newbie with Javascript and you'll get my point. I downloaded the newest jQuery and named it as 'jquery.js'
Here's some source:

...

...

                ...

And then CSS:
#smallwindow    { float:left; overflow/*-y*/: hidden; width:890px; } /* overflow-y whips out the vertical scrollbar */

div.smallpics   { float:left; position:relative;  width:1595px; }

#previmg, #nextimg { float: left; width: 17px; height: 54px; background: white; overflow: hidden; background: url("images/galleryarrows_17x54.jpg"); }
#previmg        { background-position: left top; margin-right: 1px; left top; }
#nextimg        { background-position: right top; position: absolute; float: right; left: 935px; margin-left: 1px; margin-right: 1px; }
#previmg:hover  { background-position: left bottom; }
#nextimg:hover  { background-position: right bottom; }

.smallpics ul   { list-style: none; padding: 0; margin: 0; }

.smallpics li   { float: left; text-align: center;  margin-right: 1px; margin-bottom: 1px; white-space: nowrap; }

Goro mentioned binding click() event to my arrow buttons, but i don't know what "function" i should type or where to put the code. I'm guessing in front of the .scrollTo event, assuming click() is even needed.
Thank you in advance! You guys are absolutely the best when it comes to programming and coding.
Comment: Several issues as far as I can see. You have put the .scrollTo event code in the title of your anchor. It probably should be in the onclick attribute instead. But when that is done the page complains about JQuery not being initialized.
Comment: Thanks, and as i understand it, you were referring to the same things that tpaksu mentioned also. Wrong sequence in .js files and some added onclick functionalities were needed.
Answer: first, you need to include your scrollto script AFTER the jquery script.

and then, you need something like this:
$("#nextimg").on("click",function(){
    $("#smallwindow").scrollTo( '50%', 800, {axis:'x'} );
});

The function inside the click event should change. But once you get this to work, the rest will be easy to figure out.
Comment: Thanks for the good info. It didn't occur to me that the sequence of .js -files mattered (well, i suppose jquery and then everything else), but now that i think of it, it makes all the sense in the world.

I updated the anchor the way you suggested, like so:
``

But it doesn't seem to function. I've stared at that piece of text for quite a while, i'm beginning to get a hunch of how Javascript language works, but even so, i can't seem to notice what i'm lacking :)
Comment: did you make it work? the script shouldn't be on the "title" attribute, it should be inside a `` code after the `` anchor tag.
Comment: Thanks again tpaksu, you're such an helpful person beyond belief! I thought i tried EVERYTHING and it didn't work, but as i was writing this, it occured to me as last straw: "should i put another of these scripts inside ? what do i have to lose?". AND THE MAGIC FINALLY HAPPENED!!! I'm so happy i could almost cry! ;) Though i would've assumed we define this inside  and from there i just "call out" to whatever classes or ID's i've scattered inside . It works, but is it meant to work like this? Somehow i get the feeling i could put these on an external file, muchlike with css?
Comment: I actually gave up yesterday night exhausted after a week or more of frustration and this morning i got a build of JCarousel working, but it wasn't as smooth as i hoped and felt outdated. So i opened the .js file to further tinker around with classes and values, and when i saw the code list i thought: _"this doesn't look right nor light and it's from 2006!"._ So i found a new built, which has been posted just last month @ https://github.com/jsor/jcarousel. I didn't manage to implement it yet since scrollTo is working, but it's something to look into if anybody stumbles on this post.
Comment: But now i'm very very happy and i can finally start promoting me and my site properly. I learned a lot from CSS (what to do and what definitely not to), and a bit from Javascript / jQuery thanks to you. If only i could show my gratitude more towards you, but i don't know how. Once again, take these millions of thanks and your name shall be remembered :) And if i ever stop by at Turkey / Istanbul, i'm sure to buy you few Döners (i couldn't think of anything more typical) and thensome. You are a great person tpaksu.