text:
Q: Firemonkey TEdit height I'm using Delphi Seattle and my application is for Windows Desktop.
I'm trying to change the font size of a TEdit. Consequently the height was also modified. At design time everything works well, but when I run my application TEdit ignores the height modification and the text is cut.
I've tried to find FixedHeight as suggested here, but I couldn't find this property.
Is it possible to change TEdit Heigth?

A: This can be solved by overriding the control's AdjustFixedSize method.
As explained by @chrisrolliston, Removing a FMX control's size restrictions and exemplified here:
unit Unit4;
interface
uses
  System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
  FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, FMX.Edit, MyTEdit;

type
  TForm4 = class(TForm)
    Edit1: TEdit;
    procedure FormCreate(Sender: TObject);
  end;

var
  Form4: TForm4;

implementation

{$R *.fmx}

procedure TForm4.FormCreate(Sender: TObject);
begin
  Edit1.Height := 60;
end;

end.

unit MyTEdit;
interface
uses
  FMX.Edit, FMX.Controls;

type
  TEdit = class(FMX.Edit.TEdit)
  protected
    procedure AdjustFixedSize(const Ref: TControl); override;
  end;

implementation
uses
  FMX.Types;

procedure TEdit.AdjustFixedSize(const Ref: TControl);
begin
  SetAdjustType(TAdjustType.None);
end;

end.

A: If your're using styles in StyleBook:

*

*First check style name in EditBox - look at StyleLookup of TEdit in Object inspector. If it's empty, that means default editstyle for Editbox. You should search this name in styles.

*Open current style, select you platform,  find editstyle in a list of styles.

*Change FixedHeight to 0. Also you can set Align = None to reset align height.

A: Another way to handle this if you don't want to have to subclass and create your own Edit is to use a cheating cast to perform this. This gives you access to protected methods of Edit (SetAdjustType). The following example assumes you have a Edit named wwedit3.
type
  THackStyledControl = class(TStyledControl);

procedure TValidationDemoForm.FormCreate(Sender: TObject);
begin
  wwedit3.ApplyStyleLookup; // Necessary or AdjustType gets overwritten
  THackStyledControl(wwedit3)  // Removes fixed height
        .SetAdjustType(TAdjustType.None);
  wwedit3.height:= 60; // Reset the height to desired value
end;

This will work, but if you are hard coding your sizes then you need to explicitly reset your height property as the code does above. If instead you are using the align property to position your edit controls, then you don't need the additional line that sets wwedit3.height to 60


text:
Q: When I delete a shortcut folder on my desktop in Win 7, do I actually delete the real folder? Let's say that I have a folder here C:\Music
and I right click on this folder and choose create a shortcut on desktop
Now, I have a shortcut Music on my desktop.
My question is if I delete the shortcut do I delete the folder and files in the real location C:\Music?
Because If I delete a file inside this folder this file is gone also in the real location.
An if it's possible could you tell me where in Win 7 can I adjust these settings to delete or not delete the real folder and all folders and files inside etc.

A: No. When you delete the short cut, the original file or folder is not deleted

A: A shortcut is simply a file containing a link to the target.
As Xavierjazz states, the original, target, file isn't deleted if you delete the shortcut - all that happens is that you delete the shortcut file.
There is no way to change this behaviour.  All you can do is use the shortcut to take you to the target and delete it from there.

redpajama_set_name: RedPajamaStackExchange


text:
Q: LinkedIn API for share on profile I am using below code for share post on LinkedIn profile.
function share($comment, $title, $url, $imageUrl) {
          $shareUrl     =   $this->base_url . "/v1/people/~/shares";

          $xml = "<share>
                  <comment>$comment</comment>
                  <content>
                     <title>$title</title>
                     <submitted-url>$url</submitted-url>
                     <submitted-image-url>$imageUrl</submitted-image-url>
                  </content>
                  <visibility>
                     anyone
                  </visibility>
                </share>";

          $request = OAuthRequest::from_consumer_and_token($this->consumer, $this->access_token, "POST", $shareUrl);
          $request->sign_request($this->signature_method, $this->consumer, $this->access_token);
          $auth_header = $request->to_header("https://api.linkedin.com");
          if ($debug) {
              echo $xml . "\n";
              echo $auth_header . "\n";
          }
          $response = $this->httpRequest($shareUrl, $auth_header, "POST", $xml);
          return $response;
      }

But I am getting this error:
{ "errorCode": 0, "message": "[unauthorized]. The token used in the OAuth request is not valid. consumerKey: 81zzkab8nsixp6", "requestId": "GILZJ3Q4MV", "status": 401, "timestamp": 1473170097823 }
1{ "errorCode": 0, "message": "[unauthorized]. OAU:81zzkab8nsixp6|c89e142b-2525-487c-849d-eeaffca04b09|*01|*01:1473170099:V1l36ga90ipTNGKqmQ4OzUKxfoA=", "requestId": "8QWY8GGCCH", "status": 401, "timestamp": 1473170098235 }

Can anyone help to solve this error?


text:
Q: Why does JavaFX table.getItems().clear() clear the ObservableList as well I've a JavaFX table defined as:
TableView<Person> table = new TableView<>;
//Person Class contains firstName,lastName & email properties
//table has three columns First Name, Last Name & Email

An ObservableList of Persons
ObservableList<Person> persons = FXCollections.observableArrayList();

A background service, which task is to populate the table dynamically by adding entries(Person objects) to the ObservableList persons.
table is binded as:
table.itemsProperty().bind(service.valueProperty());

Everything is working fine... but I've recently found that if I clear the table items by
table.getItems().clear();

It does not only clears the table, but also the ObservableList persons. I'm wondering if this a bidirectional binding?
Even if I unbind it before calling getItems().clear() on the table, it produces same result.
Could someone explain what the point I'm not getting here?

A: When you set the itemsProperty of a TableView, what you are actually doing is to set the reference (pointer) stored in the property, to point to the specified ObservableList, rather that making an exact copy of the specified list.
Therefore, when you call getItems, it returns the reference to the specified list.
Therefore, if you call clear() on this list, you will clear the original ObservableList.

Note:
In most of the cases the binding what you have tried is not necessary:
table.itemsProperty().bind(service.valueProperty());

and it is enough to simply set the itemsProperty like
table.setItems(service.valueProperty().get());

The binding is only necessary if you plan that the reference stored in valueProperty will point to another list in runtime. In most of the cases it is enough that the table gets notifications on the changes of the list.


text:
Q: Custom Protocol Handler OSX I am attempting to create an application on OSX that uses a custom protocol handler. It's pretty well documented how to do this but I am running into an issue. This is my process:
Using Automator, I created an application called MyApp that runs the following test applescript:
display dialog "test1"
on open location this_URL
    display dialog "test2"
end open location

Then I update the plist dict by appending the following in order to use the custom myprotocol:// handler:
    <key>CFBundleIdentifier</key>
    <string>com.apple.automator.MyApp</string>
    <key>CFBundleURLTypes</key>
    <array>
      <dict>
        <key>CFBundleURLName</key>
        <string>myprotocol</string>
        <key>CFBundleURLSchemes</key>
        <array>
          <string>myprotocol</string>
        </array>
      </dict>
    </array>

I register the protocol by opening the app. Only the first "test1" dialog pops up as expected.
But then when I launch the app using a browser (tested on both Chrome and Safari), still only the first "test1" dialog pops up. Why is the second "test2" dialog being skipped? Ultimately the test code will be replaced and I'll need the this_URL information for the app to run.
I've tried this on two different machines (both Big Sur and Catalina).
Thanks for the help.


text:
Q: What is the difference between handle and thread? I see in Windows Task Manager -> Performance tab under system block, I see Process, threads and handle statistics.
Can some body tell me what are handles(with technical information including development point of view)?

A: A thread is part of the process, running within its own execution space and there can be multiple threads in one process.
with the help of it os can do multiple tasks in parallel(depends upon the number of processors of the machine.
A handle is a generic OS term that can be a  ticket to an operating system object. Each handle is unique and identifies each object. A thread is an OS object and each one you create, you get back a handle for it.
Under Windows, the thread handle is different from the thread ID, in the same way that a file handle is different from a file name.
The thread handle is a token which allows you to do something with the thread (typically wait for it or kill it). Win32 has these tokens for lots of objects, and calls them HANDLE in general.


text:
Q: Getting the address of a pointer My apologies, I know there are a million questions on pointers, arrays etc. although as basic as this is I just can't seem to find anything pointing (ha ha!) to an answer.
I've got a pointer that is initialised to point to a chunk of memory, I understand that I can access this memory similar to how I would an array:
char *mMem=new char[5000];
cout<<mMem[5]<<endl;

Which is actually:
char *mMem=new char[5000];
cout<<*(mMem+5)<<endl;

What I don't understand though is how to get the address of an element - I'm aware that element isn't quite the right word considering mMem isn't an array - that's if my understanding is correct, can't be too sure though because it seems every site uses whatever words it wants when it comes to pointers and arrays. So, if I have:
char *mMem=new char[5000];
cout<<mMem[5]<<endl;
    or
cout<<*(mMem+5)<<endl;

why does the address of operator not work correctly:
cout<<&mMem[5]<<endl;

Instead of getting the address of the 5th element, I get a print out of the memory block contents from that element onwards. So, why did the address of operator not work as I was expecting and how can I get the address of an element of the memory?

A: You are getting the address of element 5 as you expect, but the cout print functionality for a char * is to print out the string contents at that memory location, not the pointer value.
Cast the pointer to an int: cout << (int)&mMem[5]; and you should get the address printed.

A: &mMem[5] is the address of the 5th element. The reason why you get a printout of the memory from there is because they type of &mMem[5] is char*, but strings in legacy C are also of char*, so the << operator simply thinks that you want to print a string from there. I would try casting the pointer to a void* before printing:
cout << static_cast<void*>(&mMem[5]) << endl;

By the way, &mMem[5] and mMem+5 are just the same.


text:
Q: Centos 7 installer shows incorrect free space I booted from a USB to install centos7 onto another USB.
However, when I tried to select the installation destination, the installer showed incorrect (very little) free space on all my devices, shown as in the figure below.
Indeed both sdb and sdc are empty, formatted in FAT32 and NTFS, respectively.
sda is the HDD on my PC, which is also only about 50% full.
Anyone knows how this can happen?
installation destination

A: OK, the answer seems that I have to delete the partition first on the "installation destination" page, although the devices are originally empty. After deletion the devices become completely free and I can allocate the mount points.


text:
Q: problem with auto_route package after upgrading flutter to ^2.0.0 My code was working without problem. But after the update I had problems in my "router.gr.dart" associate.
// **************************************************************************
// AutoRouteGenerator (router.gr.dart)
// **************************************************************************

import 'package:flutter/material.dart';
import 'package:flutter/cupertino.dart';
import 'package:auto_route/auto_route.dart';
import 'package:potbelly/screens/localisationscreen_page.dart';
import 'package:potbelly/screens/loc-products-screen.dart';
import 'package:potbelly/screens/login_screen.dart';
import 'package:potbelly/screens/splash_screen.dart';
import 'package:potbelly/screens/forgot_password_screen.dart';
import 'package:potbelly/screens/register_screen.dart';
import 'package:potbelly/screens/set_location_screen.dart';
import 'package:potbelly/screens/home_screen.dart';
import 'package:potbelly/screens/root_screen.dart';
import 'package:potbelly/routes/router.dart';
import 'package:potbelly/screens/profile_screen.dart';
import 'package:potbelly/screens/notification_screen.dart';
import 'package:potbelly/screens/trending_restaurant_screen.dart';
import 'package:potbelly/screens/restaurant_details_screen.dart';
import 'package:potbelly/screens/bookmarks_screen.dart';
import 'package:potbelly/screens/filter_screen.dart';
import 'package:potbelly/screens/search_results.dart';
import 'package:potbelly/screens/review_rating_screen.dart';
import 'package:potbelly/screens/add_ratings_screen.dart';
import 'package:potbelly/screens/menu_photos_screen.dart';
import 'package:potbelly/screens/preview_menu_photos.dart';
import 'package:potbelly/screens/categories_screen.dart';
import 'package:potbelly/screens/category_detail_screen.dart';
import 'package:potbelly/screens/find_friends_screen.dart';
import 'package:potbelly/screens/settings_screen.dart';
import 'package:potbelly/screens/change_password_screen.dart';
import 'package:potbelly/screens/change_language_screen.dart';
import 'package:potbelly/screens/edit_profile_screen.dart';
import 'package:potbelly/screens/new_review_screen.dart';

class AppRouter {
  static const loginScreen = '/';
  static const localisationScreen = '/localisationscreen_page';
  static const splashScreen = '/splash-screen';
  static const forgotPasswordScreen = '/forgot-password-screen';
  static const registerScreen = '/register-screen';
  static const setLocationScreen = '/set-location-screen';
  static const homeScreen = '/home-screen';
  static const rootScreen = '/root-screen';
  static const profileScreen = '/profile-screen';
  static const notificationsScreen = '/notifications-screen';
  static const trendingRestaurantsScreen = '/trending-restaurants-screen';
  static const restaurantDetailsScreen = '/restaurant-details-screen';
  static const bookmarksScreen = '/bookmarks-screen';
  static const filterScreen = '/filter-screen';
  static const searchResultsScreen = '/search-results-screen';
  static const reviewRatingScreen = '/review-rating-screen';
  static const addRatingsScreen = '/add-ratings-screen';
  static const menuPhotosScreen = '/menu-photos-screen';
  static const previewMenuPhotosScreen = '/preview-menu-photos-screen';
  static const categoriesScreen = '/categories-screen';
  static const locProductsScreen = '/loc-products-screen';
  static const categoryDetailScreen = '/category-detail-screen';
  static const findFriendsScreen = '/find-friends-screen';
  static const settingsScreen = '/settings-screen';
  static const changePasswordScreen = '/change-password-screen';
  static const changeLanguageScreen = '/change-language-screen';
  static const editProfileScreen = '/edit-profile-screen';
  static const newReviewScreen = '/new-review-screen';

  static final navigator = ExtendedNavigator();
  static Route<dynamic> onGenerateRoute(RouteSettings settings) {
    final args = settings.arguments;
    switch (settings.name) {
      case AppRouter.loginScreen:
        return CupertinoPageRoute<dynamic>(
          builder: (_) => LoginScreen(),
          settings: settings,
        );
      case AppRouter.localisationScreen:
        return CupertinoPageRoute<dynamic>(
          builder: (_) => Localisation(),
          settings: settings,
        );
      case AppRouter.splashScreen:
        return CupertinoPageRoute<dynamic>(
          builder: (_) => SplashScreen(),
          settings: settings,
        );
      case AppRouter.forgotPasswordScreen:
        return CupertinoPageRoute<dynamic>(
          builder: (_) => ForgotPasswordScreen(),
          settings: settings,
        );
      case AppRouter.registerScreen:
        return MaterialPageRoute<dynamic>(
          builder: (_) => RegisterScreen(),
          settings: settings,
        );
      case AppRouter.setLocationScreen:
        return CupertinoPageRoute<dynamic>(
          builder: (_) => SetLocationScreen(),
          settings: settings,
        );
      case AppRouter.homeScreen:
        if (hasInvalidArgs<Key>(args)) {
          return misTypedArgsRoute<Key>(args);
        }
        final typedArgs = args as Key;
        return CupertinoPageRoute<dynamic>(
          builder: (_) => HomeScreen(key: typedArgs),
          settings: settings,
        );
      case AppRouter.rootScreen:
        if (hasInvalidArgs<CurrentScreen>(args)) {
          return misTypedArgsRoute<CurrentScreen>(args);
        }
        final typedArgs = args as CurrentScreen;
        return CupertinoPageRoute<dynamic>(
          builder: (_) => RootScreen(currentScreen: typedArgs),
          settings: settings,
        );
      case AppRouter.profileScreen:
        if (hasInvalidArgs<Key>(args)) {
          return misTypedArgsRoute<Key>(args);
        }
        final typedArgs = args as Key;
        return CupertinoPageRoute<dynamic>(
          builder: (_) => ProfileScreen(key: typedArgs),
          settings: settings,
        );
      case AppRouter.notificationsScreen:
        if (hasInvalidArgs<Key>(args)) {
          return misTypedArgsRoute<Key>(args);
        }
        final typedArgs = args as Key;
        return CupertinoPageRoute<dynamic>(
          builder: (_) => NotificationsScreen(key: typedArgs),
          settings: settings,
        );
      case AppRouter.trendingRestaurantsScreen:
        return CupertinoPageRoute<dynamic>(
          builder: (_) => TrendingRestaurantsScreen(),
          settings: settings,
        );
      case AppRouter.restaurantDetailsScreen:
        if (hasInvalidArgs<RestaurantDetails>(args, isRequired: true)) {
          return misTypedArgsRoute<RestaurantDetails>(args);
        }
        final typedArgs = args as RestaurantDetails;
        return CupertinoPageRoute<dynamic>(
          builder: (_) => RestaurantDetailsScreen(restaurantDetails: typedArgs),
          settings: settings,
        );
      case AppRouter.bookmarksScreen:
        return CupertinoPageRoute<dynamic>(
          builder: (_) => BookmarksScreen(),
          settings: settings,
        );
      case AppRouter.filterScreen:
        return CupertinoPageRoute<dynamic>(
          builder: (_) => FilterScreen(),
          settings: settings,
        );
      case AppRouter.searchResultsScreen:
        if (hasInvalidArgs<SearchValue>(args)) {
          return misTypedArgsRoute<SearchValue>(args);
        }
        final typedArgs = args as SearchValue;
        return CupertinoPageRoute<dynamic>(
          builder: (_) => SearchResultsScreen(typedArgs),
          settings: settings,
        );
      case AppRouter.reviewRatingScreen:
        return CupertinoPageRoute<dynamic>(
          builder: (_) => ReviewRatingScreen(),
          settings: settings,
        );
      case AppRouter.addRatingsScreen:
        return CupertinoPageRoute<dynamic>(
          builder: (_) => AddRatingsScreen(),
          settings: settings,
        );
      case AppRouter.menuPhotosScreen:
        return CupertinoPageRoute<dynamic>(
          builder: (_) => MenuPhotosScreen(),
          settings: settings,
        );
      case AppRouter.previewMenuPhotosScreen:
        return CupertinoPageRoute<dynamic>(
          builder: (_) => PreviewMenuPhotosScreen(),
          settings: settings,
        );
      case AppRouter.categoriesScreen:
        return CupertinoPageRoute<dynamic>(
          builder: (_) => CategoriesScreen(),
          settings: settings,
        );
      case AppRouter.locProductsScreen:
        return CupertinoPageRoute<dynamic>(
          builder: (_) => LocProductsScreen(),
          settings: settings,
        );
      case AppRouter.categoryDetailScreen:
        if (hasInvalidArgs<CategoryDetailScreenArguments>(args,
            isRequired: true)) {
          return misTypedArgsRoute<CategoryDetailScreenArguments>(args);
        }
        final typedArgs = args as CategoryDetailScreenArguments;
        return CupertinoPageRoute<dynamic>(
          builder: (_) => CategoryDetailScreen(
              categoryName: typedArgs.categoryName,
              imagePath: typedArgs.imagePath,
              numberOfCategories: typedArgs.numberOfCategories,
              selectedCategory: typedArgs.selectedCategory,
              gradient: typedArgs.gradient),
          settings: settings,
        );
      case AppRouter.findFriendsScreen:
        return CupertinoPageRoute<dynamic>(
          builder: (_) => FindFriendsScreen(),
          settings: settings,
        );
      case AppRouter.settingsScreen:
        return CupertinoPageRoute<dynamic>(
          builder: (_) => SettingsScreen(),
          settings: settings,
        );
      case AppRouter.changePasswordScreen:
        return CupertinoPageRoute<dynamic>(
          builder: (_) => ChangePasswordScreen(),
          settings: settings,
        );
      case AppRouter.changeLanguageScreen:
        return CupertinoPageRoute<dynamic>(
          builder: (_) => ChangeLanguageScreen(),
          settings: settings,
        );
      case AppRouter.editProfileScreen:
        return CupertinoPageRoute<dynamic>(
          builder: (_) => EditProfileScreen(),
          settings: settings,
        );
      case AppRouter.newReviewScreen:
        return CupertinoPageRoute<dynamic>(
          builder: (_) => NewReviewScreen(),
          settings: settings,
        );
      default:
        return unknownRoutePage(settings.name);
    }
  }
}

//**************************************************************************
// Arguments holder classes
//***************************************************************************

//CategoryDetailScreen arguments holder class
class CategoryDetailScreenArguments {
  final String categoryName;
  final String imagePath;
  final int numberOfCategories;
  final int selectedCategory;
  final Gradient gradient;
  CategoryDetailScreenArguments(
      {@required this.categoryName,
      @required this.imagePath,
      @required this.numberOfCategories,
      @required this.selectedCategory,
      @required this.gradient});
}

"ExtendedNavigator" is displayed as an error although before it was working:
enter image description here
Then I have "hasInvalidArgs" and "misTypedArgsRoute" which show up as errors:
enter image description here
And finally I have "unknownRoutePage" which no longer works either:
enter image description here
If anyone can help me that would be nice :)
I've been looking for a solution for several days now but I can't find anything :/


text:
Q: Align navbar bootstrap 4 to the right I'm trying to use the new version of Bootstrap for a personnal project. I tried to make a navbar, and I want the links to be aligned to the right, and I looked for a solution but I couldn't find how to do it.
Here's my code

    <button class="navbar-toggler navbar-toggler-right" type="button" data-toggle="collapse"
            data-target="#navbarNavAltMarkup" aria-controls="navbarNavAltMarkup" aria-expanded="false"
            aria-label="Toggle navigation">

    </button>
    taïho sushi

            Présentation
            Menu
            Contact

A: Use the new ml-auto class which sets margin-left:auto and pushes the content to the right.

    <button class="navbar-toggler navbar-toggler-right" type="button" data-toggle="collapse"
            data-target="#navbarNavAltMarkup" aria-controls="navbarNavAltMarkup" aria-expanded="false"
            aria-label="Toggle navigation">

    </button>
    taïho sushi

            Présentation
            Menu
            Contact

Demo on Codeply

A: use navbar-right class

    <button class="navbar-toggler navbar-toggler-right" type="button" data-toggle="collapse"
            data-target="#navbarNavAltMarkup" aria-controls="navbarNavAltMarkup" aria-expanded="false"
            aria-label="Toggle navigation">

    </button>
    taïho sushi

            Présentation
            Menu
            Contact


text:
Q: Would this not take a ridiculously long calculation? (Surface area of parametric surface) One of the question in my homework asks to verify that the surface are of
$ \mathbf{r} = a(1+\cos\phi)\sin\phi \cos\theta \mathbf{i} + a(1+\cos\phi)\sin\phi \sin\theta \mathbf{j} + a(1+\cos\phi)\cos\phi \mathbf{k}$
is $\frac{32}{5}\pi a^2$
I started with the equation to the area of the surface being the double integral of $|\mathbf{r}_{\phi} \times \mathbf{r}_{\theta}|$... but MAN this is so long it's almost unworkable. Am I doing this the stupid way? Can this be simplified?
All I can tell is that $\mathbf{r} = a\sin\phi \cos\theta \mathbf{i} + a\sin\phi \sin\theta \mathbf{j} + a\cos\phi \mathbf{k}$ is te equation of a sphere of radius $a$, but you can't really factor out areas, that I know of... so I don't see how this helps.

A: I'll ignore the common scaling factor of $a$; we can multiply by $a^2$ at the end.
The surface is a surface of revolution about the symmetry axis of a cardioid:
$$\mathbf r = (f(\phi)\cos\theta, f(\phi)\sin\theta, g(\phi))$$
with
$$f(\phi) = (1+\cos\phi)\sin\phi = \sin\phi + \sin(2\phi)$$
$$g(\phi) = (1+\cos\phi)\cos\phi = \cos\phi + \cos(2\phi) + 1/2$$
Therefore we can use the formula for the area of a surface of revolution:
$$A = 2\pi \int_0^\pi f(\phi)\sqrt{f'(\phi)^2+g'(\phi)^2} \;d\phi$$
where only the range $[0,\pi]$ for $\phi$ is relevant because $f$ is odd and $g$ is even. The expression under the square root is
$$\begin{align} &\big(-\sin\phi - \sin(2\phi)\big)^2 + \big(\cos\phi - \cos(2\phi)\big)^2\\
=&\sin^2\phi+\cos^2\phi + \sin^2(2\phi)+\cos^2(2\phi) + 2\Bigl(\sin\phi\sin(2\phi)+\cos\phi\cos(2\phi)\Bigr) \\
=&2+2\Bigl(\sin\phi(2\cos\phi\sin\phi)+\cos\phi(2\cos^2\phi-1)\Bigr) \\
=&2+2(2\cos\phi-\cos\phi) = 2(1+\cos\phi)
\end{align}$$
so we get
$$A = 2\pi \int_0^\pi \sqrt 2 (1+\cos\phi)^{3/2} \sin \phi\; d\phi$$
which is easily evaluated by substituting $u=1+\cos\phi$.

A: I don't really see anything that can significantly help cut down on your calculations.
This is the sort of problem I like to throw to Maple.
Maple finds that
$${\bf r}_\theta \times {\bf r}_\phi = \begin{array}{l} (-a^2\sin^2(\phi)\cos(\theta)(3\cos(\phi)+1+2\cos^2(\phi))){\bf i}\\ (-a^2\sin^2(\phi)\sin(\theta)(3\cos(\phi)+1+2\cos^2(\phi))){\bf j}\\ (-a^2\sin(\phi)(-1+3\cos^2(\phi)+2\cos^3(\phi))){\bf k}\end{array}$$
Then $|{\bf r}_\theta \times {\bf r}_\phi| = a^2\sqrt{2}\sin(\phi)(1+\cos(\phi))^{3/2}$
Integrating over $0 \leq \phi \leq \pi$ and $0 \leq \theta \leq 2\pi$ gives $\frac{32}{5}a^2\pi$ as predicted.

A: The surface is a surface of revolution around the $z$-axis. The meridian curve $\gamma$ in the $(\rho,z)$-halfplane is given by
$$\gamma:\quad \phi\mapsto\bigl((1+\cos\phi)\sin\phi,(1+\cos\phi)\cos\phi\bigr)\qquad(0\leq\phi\leq\pi)\ ;$$
whence it has the simple polar representation
$$\gamma:\qquad r(\phi):=1+\cos\phi\quad(0\leq\phi\leq\pi)\ .$$
It follows that its line element is given by
$$ds=\sqrt{r^2+r'^2}\ d\phi=\sqrt{2(1+\cos\phi)}\ d\phi\ .$$
To this line element belongs the annular area element
$$d\omega=2\pi\rho(\phi)ds=2\pi\sqrt{2}(1+\cos\phi)^{3/2}\sin\phi\ d\phi=-2\pi\sqrt{2}\bigl(r(\phi)\bigr)^{3/2}r'(\phi)\ d\phi\ .$$
Therefore we get by integration
$$\omega(S)=-2\pi\sqrt{2}\int_0^\pi \bigl(r(\phi)\bigr)^{3/2}r'(\phi)\ d\phi =
-2\pi\sqrt{2}{2\over5}\bigl(r(\phi)\bigr)^{5/2}\Biggr|_0^\pi ={32\pi\over5}\ .$$


text:
Q: http and https with 2 different domains in a single nginx server I am using nginx in my aws server and hosting 2 ruby on rails apps there. HTTPS is enable in one of my server (example.com is below example file) and other server is on HTTP (test.com).
Now the problem which I am facing is https://test.com is able to access example.com (which should not happen). test.com is configured for port 80 and it is also able to access port 443.
Here is my nginx configuration file :
upstream example {
  server unix:///tmp/example.sock;
}

upstream test {
  server unix:///tmp/test.sock;
}

server {
  listen 80;
  server_name example.com; # change to match your URL
  return         301 https://$server_name$request_uri;
}

server {
  listen 443 default;
  server_name example.com;

  root /home/deploy/example/current/public;
  ssl on;
  ssl_certificate /etc/nginx/ssl/example.com.crt;
  ssl_certificate_key /etc/nginx/ssl/example.com.key;

  location / {
    client_max_body_size 15M;
    client_body_buffer_size 128k;
    proxy_pass http://example; # match the name of upstream directive which is defined above
    proxy_set_header Host $host;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto  $scheme;
  }

  location ~* ^/assets/ {
    # Per RFC2616 - 1 year maximum expiry
    expires 1y;
    add_header Cache-Control public;

    # Some browsers still send conditional-GET requests if there's a
    # Last-Modified header or an ETag header even if they haven't
    # reached the expiry date sent in the Expires header.
    add_header Last-Modified "";
    add_header ETag "";
    break;
  }
}

server {
  listen 80 default_server;
  server_name test.com www.test.com blog.test.com; # change to match your URL
  root /home/deploy/test/current/public; # I assume your app is located at this location

  location / {
    proxy_pass http://test; # match the name of upstream directive which is defined above
    proxy_set_header Host $host;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  }

  location ~* ^/assets/ {
    # Per RFC2616 - 1 year maximum expiry
    expires 1y;
    add_header Cache-Control public;

    # Some browsers still send conditional-GET requests if there's a
    # Last-Modified header or an ETag header even if they haven't
    # reached the expiry date sent in the Expires header.
    add_header Last-Modified "";
    add_header ETag "";
    break;
  }
}

A: If you have only one IP address, you can redirect https://test.com to http://test.com with a new server section like this:
server {
    listen              443 ssl;
    server_name         test.com www.test.com blog.test.com;
    ssl_certificate     example_or_test.com.crt;
    ssl_certificate_key example_or_test.com.key;
    return         301 http://$server_name$request_uri;
}

Unfortunately, this solution will issue warnings in browsers if you do not have a valid certificat for test.com or if you use the example.com certificat.
Old reply
You can use:
server {
    listen              80;
    listen              443 ssl;
    server_name         www.example.com;
    ssl_certificate     www.example.com.crt;
    ssl_certificate_key www.example.com.key;
    ...
}

See: http://nginx.org/en/docs/http/configuring_https_servers.html#single_http_https_server
If you have only one IP, NGinx support SNI.
See: http://nginx.org/en/docs/http/configuring_https_servers.html#sni


text:
Q: Compile production assets from clojurescript with figwheel We currently use cljsbuild to compile our clojurescript source into the assets used in production, but during development, we use lein-figwheel. Both cljsbuild and figwheel are constantly watching for changes of the source and recompile when necessary.
I was wondering, whether it's possible to use just one tool for both, preferably in the same process.
We're fine with switching tools, especially Figwheel Main. Each file change should just compile:

*

*a js with advanced optimizations to be used in production

*live reload the code in the browser as figwheel & figwheel main do it

I found this in the figwheel documentation, but it requires manual work like cleaning targets and running the build on demand with special options.

A: I recently switched from lein-figwheel to figwheel-main (using Clojure Deps in place of lein). Figwheel-Main is much simpler, easier & better (basically it is "Figwheel 2.0").
Figwheel-Main can be used for both the auto-reloading during development and for compiling a single my-app.js output file for deployment or testing.  You can use either :whitespace or :advanced compiler optimization level to get a single static *.js output file.  I use :whitespace to generate an output file for standalone testing purposes (in Docker with chrome --headless) or :advanced for the final production build.
As a side benefit, Clojure Deps is better than lein for managing conflicting dependency versions.


text:
Q: Evaluating $\int_0^a dx\frac{\Gamma(1+x)}{\Gamma(1+x+a)}x^n$? Is it known in the literature how the following integral can be evaluated analytically?
$$\int_0^a dx\frac{\Gamma(1+x)}{\Gamma(1+x+a)}x^n=???$$
where $a>0$ and $n\in\mathbb{Z}^*$.
I've tried using series representations and integral representations of Γ(z) and 1/Γ(z) to first obtain a simple integral in x and then consider resumming the expansions. That did not help much. Additionally, Gradshteyn and Ryzhik does not seem to contain the answer either.


text:
Q: VHF/UHF vs 2.4GHz/5GHz Was curious if you anyone had information as to why 5GHz wifi is more susceptible to walls and floors in buildings (as compared to 2.4Ghz) but the opposite seems to be true for VHF vs UHF. We tend to use VHF radios outdoors and UHF radios more indoors.  Seems like 5GHz is to UHF (both higher freq) as 2.4GHz is to VHF (both lower freq); and yet seems like the penetrative properties are opposite.

A: This is not the answer that you want to hear :-) :-(.
Propagation in buildings and tunnels and similar is complex.
During "911" they had disastrous results trying to use radios in buildings. A significant number of reports were written and they tended to conclude that around 800 Mhz was optimum. I read through the technical part of a number of these reports for essentially unrelated reasons* trying to find out the basis for their calculations. I found that all who gave a basis cited a single report that used a formula that was appropriate in its original context but randomly related to its use elsewhere. The parameter related to "roughness" of surfaces which tend to rotate the polarisation of the original wave with distance.
SO
You need to look at the equations for propagation and then decide what parameters are relevant and what they should be set to.
Conclusion: Magic is required - there are too many variables with semi random values that vary case by case. Obviously (or luckily) there must be frequencies that work somewhat better in some typical sets of cases to be useful generalisations.

Not all the papers over time did as I claim above - but whether they are useful in practice is moot. Most deal with internal space as tunnels - buildings tend to be tunnels with reflective attenuators (aka walls) in them to increase the fun level.
Here is one reference which comes to hand
ATTENUATION CONSTANTS OF RADIO WAVES IN
LOSSY-WALLED RECTANGULAR WAVEGUIDES 2013 31pp.
So you know what you're in for :-)

*

*Abstract:
At the ultra-high frequencies (UHF) common to portable radios, the mine tunnel acts as a dielectric waveguide, directing and absorbing energy as a radio signal propagates. Understanding radio propagation behavior in a dielectric waveguide is critical for designing reliable, optimized communication systems in an underground mine. One of the major parameters used to predict the power attenuation in lossy waveguides is the attenuation constant. In this paper, we theoretically and experimentally investigate the attenuation constants for a rectangular waveguide with dielectric walls. We provide a new derivation of the attenuation constant based on the classic Fresnel reflection coefficients. The new derivation takes advantage of ray representation of plane waves and provides more insight into understanding radio attenuation in tunnels. We also investigate the impact of different parameters on the attenuation constant, including the tunnel transverse dimensions, permittivity, conductivity, frequency, and polarization, with an aim to find their theoretical optimal values that result in the minimum power loss. Additionally, measurements of the attenuation constants of the dominant mode at different frequencies (455, 915, 2450, and 5800 MHz) for a straight concrete tunnel are presented and compared to theoretical predictions. It is shown that the analytical results match the measured results very well at all four frequencies.

Mother lode - maybe:
Here are references to a months plus solid reading while in self isolation. How useful they will be is tbd. This link will work after my PC next boots as Dropbox says it is not sinking at present. It is an RTF file containing 50+ live links and 30 or so citations - all of variable relevance.
Tunnel {&building} communications
I tried to use
bit.ly/tunnelcoms <- please use
which allows me to see how many people accessed the link but the stupid SE system abhors such an equally good method (for reasons which are understood bu inlaid in cases like this one).
 People interested enough to look at the references would do themselves and me a favour by using the bit.ly link.

A: It's used because it's an available unlicensed spectrum (same for 2.4GHz and 929-933 MHz.)
But, yes, range through obstructions for these Wi-Fi bands is poor.


text: Q: Change the packet flow through one router to another in NS2 Please let me know how to change the flow of packets through (A to B) to (A to C) where B and C are nodes connected to a particular LAN. Let us assume that we have to bring the change of flow after time t.


text:
Q: Proof that the quotient of equal rank free abelian groups is finite? Let $G$ be a free abelian group with finite rank and $H$ be a subgroup of $H$ such that $rank(G)=rank(H)$.
Then, why is $G/H$ finite?
Since $G/H$ is finitely generated, there is a free abelian group $L$ and a finite abelian group $F$ such that $G/H\cong L\times F$. Why should $L$ be of rank $0$?

A: A nontorsion element of $G/H$ could be pulled back to $G$ and then adjoined to a maximal $\mathbb{Z}$-independent subset of $H$ to get a bigger $\mathbb{Z}$-independent subset of $G$ (prove this), a contradiction.
Finitely-generated torsion abelian implies finite.

A: This follows from the basic theorem (part of the subject of f.g. abelian groups and f.g. free abelian groups) that since $\;G\;$ is a f.g. free abelian group, then there exists a (free, to be sure) basis $\;g_1,...,g_n\;$ of $\;G\;$ and integers $\;m_1,...,m_n\;$ such that $\;m_1g_1,...,m_ng_n\;$ is a basis of $\;H\;$ . In fact, the integers $\;m_i\;$ also fulfill several divisibility conditions, but we don't care about that now.
Thus, if $\;x+H\in G/H\;$ , we get that
$$m_1\cdot\ldots\cdot m_n(x+H)=m_1\cdot\ldots\cdot m_n x+H=H\;\;\;\implies $$
$\;G/H\;$ is torsion, and since  it is f.g. it is then finite.


text:
Q: STM32F401RE SPI DMA flash driver read/write not working I am facing problem with STM32F401RE with SPI flash driver.
I am able to do normal SPI operations like read,write etc...
But I need to use DMA to read and write to FLASH.
/********************************
I am trying to read the data(DMA Methos) from specific address location 0x700000 which was written already.
*********************/
Now I was able to DMA sent sucessfully but on the DMA Receiving buffer it has starting four bytes of NULL data followed by actual Data and last four bytes are missing.
Original: STM32F4xx SPI Firmware Library Example: communication with an S25FL164K SPI FLASH from SPANSION
Receiving : "0x00 0x00 0x00 0x00 STM32F4xx SPI Firmware Library Example: communication with an S25FL164K SPI FLASH from SPAN"
Can some one please suggest why I am getting junk characters like NULL in the first four bytes and why the last four bytes are missing??
Is there any issue issues with clock cycles??
And one more thing I have to clear/read all the data present on "SPI1->DR " before the dma transfer
This is the code..
Please suggest if any issues in the below code
   SPI_InitTypeDef  SPI_InitStructure;
   GPIO_InitTypeDef GPIO_InitStructure;

/*!< Enable the SPI clock */
sFLASH_SPI_CLK_INIT(sFLASH_SPI_CLK, ENABLE);

/*!< Enable GPIO clocks */

/*!< Enable GPIO clocks */
RCC_AHB1PeriphClockCmd(sFLASH_SPI_SCK_GPIO_CLK | sFLASH_SPI_MISO_GPIO_CLK |
                     sFLASH_SPI_MOSI_GPIO_CLK | sFLASH_CS_GPIO_CLK, ENABLE);

RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_DMA2, ENABLE);
/*!< SPI pins configuration *************************************************/

/*!< Connect SPI pins to AF5 */
GPIO_PinAFConfig(sFLASH_SPI_SCK_GPIO_PORT, sFLASH_SPI_SCK_SOURCE, sFLASH_SPI_SCK_AF);
GPIO_PinAFConfig(sFLASH_SPI_MISO_GPIO_PORT, sFLASH_SPI_MISO_SOURCE, sFLASH_SPI_MISO_AF);
GPIO_PinAFConfig(sFLASH_SPI_MOSI_GPIO_PORT, sFLASH_SPI_MOSI_SOURCE, sFLASH_SPI_MOSI_AF);
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_PuPd  = GPIO_PuPd_DOWN;

/*!< SPI SCK pin configuration */
GPIO_InitStructure.GPIO_Pin = sFLASH_SPI_SCK_PIN;
GPIO_Init(sFLASH_SPI_SCK_GPIO_PORT, &GPIO_InitStructure);

/*!< SPI MOSI pin configuration */
GPIO_InitStructure.GPIO_Pin =  sFLASH_SPI_MOSI_PIN;
GPIO_Init(sFLASH_SPI_MOSI_GPIO_PORT, &GPIO_InitStructure);

/*!< SPI MISO pin configuration */
GPIO_InitStructure.GPIO_Pin =  sFLASH_SPI_MISO_PIN;
GPIO_Init(sFLASH_SPI_MISO_GPIO_PORT, &GPIO_InitStructure);

/*!< Configure sFLASH Card CS pin in output pushpull mode ********************/
GPIO_InitStructure.GPIO_Pin = sFLASH_CS_PIN;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
GPIO_Init(sFLASH_CS_GPIO_PORT, &GPIO_InitStructure);

/*!< Deselect the FLASH: Chip Select high */
sFLASH_CS_HIGH();

/*!< SPI configuration */
SPI_InitStructure.SPI_Direction = SPI_Direction_2Lines_FullDuplex;
SPI_InitStructure.SPI_Mode = SPI_Mode_Master;
SPI_InitStructure.SPI_DataSize = SPI_DataSize_8b;
SPI_InitStructure.SPI_CPOL = SPI_CPOL_Low;
SPI_InitStructure.SPI_CPHA = SPI_CPHA_1Edge;
SPI_InitStructure.SPI_NSS = SPI_NSS_Soft;
SPI_InitStructure.SPI_BaudRatePrescaler = SPI_BaudRatePrescaler_4;
SPI_InitStructure.SPI_FirstBit = SPI_FirstBit_MSB;
SPI_InitStructure.SPI_CRCPolynomial = 7;
SPI_Init(sFLASH_SPI, &SPI_InitStructure);
void SPI_DMA_READ(uint8_t* Addref, uint8_t* pRxBuf, uint16_t rx_len)
{
    uint16_t i;

    memset(pTmpBuf1, 0, rx_len + 3);
    memset(pTmpBuf2, 0, rx_len + 3);

      pTmpBuf1[0] = sFLASH_CMD_READ;
    pTmpBuf1[1] = Addref[0];
    pTmpBuf1[2] = Addref[1];
    pTmpBuf1[3] = Addref[2];

  DMA_InitStructure.DMA_BufferSize = (uint16_t)(rx_len);
  DMA_InitStructure.DMA_FIFOMode = DMA_FIFOMode_Disable ;
 DMA_InitStructure.DMA_FIFOThreshold = DMA_FIFOThreshold_1QuarterFull ;
  DMA_InitStructure.DMA_MemoryBurst = DMA_MemoryBurst_Single ;
  DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_Byte;
  DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable;
  DMA_InitStructure.DMA_Mode = DMA_Mode_Normal;

    DMA_InitStructure.DMA_PeripheralBaseAddr = (uint32_t)(&(SPI1->DR));
    DMA_InitStructure.DMA_PeripheralBurst = DMA_PeripheralBurst_Single;
  DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_Byte;
    DMA_InitStructure.DMA_MemoryDataSize =  DMA_MemoryDataSize_Byte;
    DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable;
    DMA_InitStructure.DMA_Priority = DMA_Priority_High;

    /* Configure Tx DMA */
    DMA_InitStructure.DMA_Channel = DMA_Channel_3;
    DMA_InitStructure.DMA_DIR = DMA_DIR_MemoryToPeripheral;
    DMA_InitStructure.DMA_Memory0BaseAddr =(uint32_t)pTmpBuf1;
    DMA_Init(DMA2_Stream3, &DMA_InitStructure);

/* Configure Rx DMA */
    DMA_InitStructure.DMA_Channel = DMA_Channel_3;
    DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralToMemory;
    DMA_InitStructure.DMA_Memory0BaseAddr =(uint32_t)pTmpBuf2;
    DMA_Init(DMA2_Stream2, &DMA_InitStructure);
 #if 1
      //DMA Interrupt Structure Initialisation
    static NVIC_InitTypeDef NVIC_InitStructure;
    NVIC_InitStructure.NVIC_IRQChannel =                  DMA2_Stream2_IRQn;//SPI_PORT_DMA_TX_IRQn;
 NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
 NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;

    //Initialise the Interrupt
NVIC_Init(&NVIC_InitStructure);

// Enable DMA1 channel IRQ Channel */
DMA_ITConfig(DMA2_Stream2, DMA_IT_TC, ENABLE);

 #endif
/* Enable the DMA channel */

   /* Enable the DMA SPI TX Stream */
DMA_Cmd(DMA2_Stream3, ENABLE);
/* Enable the DMA SPI RX Stream */
DMA_Cmd(DMA2_Stream2, ENABLE);

    /* Enable the SPI Rx DMA request */
SPI_I2S_DMACmd(SPI1, SPI_I2S_DMAReq_Rx, ENABLE);
SPI_I2S_DMACmd(SPI1, SPI_I2S_DMAReq_Tx, ENABLE);

sFLASH_CS_LOW();

while (SPI_I2S_GetFlagStatus(SPI1, SPI_I2S_FLAG_BSY) == SET)
{}

 SPI_Cmd(SPI1, ENABLE);
    while(trasfer_complete_rx == 0);
memcpy(pRxBuf, pTmpBuf2 ,rx_len);

/*******************************************/
IRQ Handler
/***************************************/
  void DMA2_Stream2_IRQHandler()
  {

if(DMA_GetITStatus(DMA2_Stream2,DMA_IT_TCIF2))
 DMA_ClearITPendingBit(DMA2_Stream2,DMA_IT_TCIF2);

DMA_ClearITPendingBit(DMA2_Stream3,DMA_IT_TCIF3);
DMA_ClearITPendingBit(DMA2_Stream2,DMA_IT_TCIF2);

DMA_Cmd(DMA2_Stream3, DISABLE);
DMA_Cmd(DMA2_Stream2, DISABLE);

SPI_I2S_DMACmd(SPI1, SPI_I2S_DMAReq_Rx, DISABLE);
SPI_I2S_DMACmd(SPI1, SPI_I2S_DMAReq_Tx, DISABLE);

SPI_Cmd(SPI1, DISABLE);
sFLASH_CS_HIGH();
trasfer_complete_rx =1;
while(USART_GetFlagStatus(USART2, USART_FLAG_TXE) == RESET); // Wait for Empty

USART_SendData(USART2,*(pTmpBuf2+2)); // Send 'I'
}

A: This is for stm32f401re
First the DMA initialization
void init_spi1_dma(void)
{
  DMA_InitTypeDef DMA_InitStructure;
  DMA_StructInit(&DMA_InitStructure);
  //
  // spi1 rx configuration
  //
  DMA_Cmd(DMA2_Stream0, DISABLE);
  while(DMA2_Stream0_BASE & 0x00000001); // wait for disable to take effect
  DMA_DeInit(DMA2_Stream0);
  DMA_InitStructure.DMA_Channel = DMA_Channel_3;
  DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralToMemory; // receive
// tell the DMA where to place the incoming characters
// in this case only one char at a time
// let the interrupt routine sort it out
  DMA_InitStructure.DMA_Memory0BaseAddr = (uint32_t)dma_rx_buffer;
  DMA_InitStructure.DMA_BufferSize = (char)sizeof(dma_rx_buffer);
  DMA_InitStructure.DMA_PeripheralBaseAddr = (uint32_t)&SPI1->DR;
  DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable;
  DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable;
  DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_Byte;
  DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_Byte;
  DMA_InitStructure.DMA_Mode = DMA_Mode_Circular;
  DMA_InitStructure.DMA_Priority = DMA_Priority_High;
  DMA_InitStructure.DMA_FIFOMode = DMA_FIFOMode_Disable;
  DMA_InitStructure.DMA_FIFOThreshold = DMA_FIFOThreshold_1QuarterFull;
  DMA_InitStructure.DMA_MemoryBurst = DMA_MemoryBurst_Single;
  DMA_InitStructure.DMA_PeripheralBurst = DMA_PeripheralBurst_Single;
  //
  // the interrupt flags for the DMA Stream:
  // DMA_IT: specifies the DMA interrupt pending bit to clear.
  //          This parameter can be any combination of the following values:
  //            DMA_IT_TCIFx:  Streamx transfer complete interrupt
  //            DMA_IT_HTIFx:  Streamx half transfer complete interrupt
  //            DMA_IT_TEIFx:  Streamx transfer error interrupt
  //            DMA_IT_DMEIFx: Streamx direct mode error interrupt
  //            DMA_IT_FEIFx:  Streamx FIFO error interrupt
  //         Where x can be 0 to 7 to select the DMA Stream.
  DMA_ClearITPendingBit(DMA2_Stream0, DMA_IT_TCIF2 | DMA_IT_TEIF2 | DMA_IT_HTIF2 | DMA_IT_FEIF2 | DMA_IT_DMEIF2);
  DMA_Init(DMA2_Stream0, &DMA_InitStructure);

// Enable the SPI Rx DMA request
  SPI_DMACmd(SPI1, SPI_DMAReq_Rx, ENABLE);
// Enable DMA Stream Transfer Complete interrupt
  DMA_ITConfig(DMA2_Stream0, DMA_IT_TC | DMA_IT_TE | DMA_IT_DME, ENABLE);
// Enable the DMA Rx Stream
  DMA_Cmd(DMA2_Stream0, ENABLE);

}

now the interrupt
//
// dma spi interrupt
//
void init_spi_dma_nvic()
{
  NVIC_InitTypeDef nvic_params;

  //NVIC_PriorityGroupConfig(NVIC_PriorityGroup_4);
  nvic_params.NVIC_IRQChannel = DMA2_Stream0_IRQn;
  nvic_params.NVIC_IRQChannelPreemptionPriority = 3;
  nvic_params.NVIC_IRQChannelSubPriority = 0;
  nvic_params.NVIC_IRQChannelCmd = ENABLE;
  NVIC_Init(&nvic_params);
}

//
// spi1 rx dma interrupt
//
void DMA2_Stream0_IRQHandler(void)
{
  static uint16_t i = 0;

  if(rcvd == 0)
    i = 0;

  rcvd++;
  /* Test on DMA Stream Transfer Complete interrupt */
  if (DMA_GetITStatus(DMA2_Stream0, DMA_IT_TCIF0))
  {
    // place the incoming char away
    rx_buffer[i++] = dma_rx_buffer[0];
    // Clear DMA Stream Transfer Complete interrupt pending bit
    DMA_ClearITPendingBit(DMA2_Stream0, DMA_IT_TCIF0);

  }
}

have fun!


text:
Q: Replace XML file or delete Element in XML file using UWP I am trying to delete an element from a xml file stored in a storage file using UWP. My problem is that the doc.Save command only adds the full doc to the end to the file instead of replacing it.
I have tried to search for som replace option but have not been successful.
So the question is actually two parts:
1. Is there a better way to remove an element from a xml file then replacing it completly?
2. If not how do I replace the file?
    public async Task DeleteSingleById(int id)
    {
        StorageFolder folder = ApplicationData.Current.LocalFolder;
        StorageFile file = await folder.GetFileAsync("Data.xml");
        Stream stream = await file.OpenStreamForWriteAsync();

        using (stream)
        {
            XDocument doc = XDocument.Load(stream);
            doc.Descendants("Companies").Elements("Company").FirstOrDefault(x => x.Elements("Id").Any(e => e.Value == id.ToString())).Remove();
            doc.Save(stream);
        }
    }

Update 1:
This solved the problem but it does not look nice. Any comments on improvements would be great.
    public async Task DeleteSingleById(int id)
    {
        StorageFolder folder = ApplicationData.Current.LocalFolder;
        StorageFile file = await folder.GetFileAsync("Data.xml");
        Stream stream = await file.OpenStreamForWriteAsync();
        XDocument doc = XDocument.Load(stream);

        using (stream)
        {
            doc.Descendants("Companies").Elements("Company").FirstOrDefault(x => x.Elements("Id").Any(e => e.Value == id.ToString())).Remove();
        }

        await file.DeleteAsync();
        file = await folder.CreateFileAsync("Data.xml", CreationCollisionOption.ReplaceExisting);
        stream = await file.OpenStreamForWriteAsync();

        using (stream)
        {
            doc.Save(stream);
        }
    }

A: The problem here is that you forgot to reset the position to the begin within the current stream, so the new XML document is appended to the original file.
To solve this problem, we can use Stream.SetLength method before saving XDocument to the stream like following. While setting the length of the current stream to zero, it will clear the current stream and automatically reset the position to the begin.
public async Task DeleteSingleById(int id)
{
    StorageFolder folder = ApplicationData.Current.LocalFolder;
    StorageFile file = await folder.GetFileAsync("Data.xml");
    Stream stream = await file.OpenStreamForWriteAsync();

    using (stream)
    {
        XDocument doc = XDocument.Load(stream);
        doc.Descendants("Companies").Elements("Company").FirstOrDefault(x => x.Elements("Id").Any(e => e.Value == id.ToString())).Remove();

        stream.SetLength(0);

        doc.Save(stream);
    }
}


text:
Q: ExoPlayer: Place controller under the video without overlapping the video I have a PlayerView that takes up the top half of the Activity in portrait orientation with the bottom half of the screen showing some text.
I need to have the controller under the video without overlapping the video content (it will always be shown). By default when a user touches the video the controller appears at the bottom of the video covering the bottom part of the video. I my case I need the controller to stick under the video with no intersections with the video content.
I went through SimpleExoPlayer and PlayerView APIs but I haven't found any way to do so.
Question: How can I place the controller under the video with ExoPlayer?
Here is how the layout looks like:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <com.google.android.exoplayer2.ui.PlayerView
        android:id="@+id/video_view"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"/>

    <TextView
        android:id="@+id/text"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentStart="true"
        android:layout_below="@id/video_view"
        android:scrollbars="vertical" />

</RelativeLayout>

A: Refer to the answer by @Pierre.
Also to remove controller from above PlayerView, in that case, @id/video_view by writing player.showController(false) in java file.
You can also use app:use_controller:false in the xml.
So you will the only the video without controller on top. And link it to a new controller, in that case, @id/controls at the bottom of the video.

A: This might give you an idea, also have you tried to override the controls?
As an example, suppose we want our playback controls to consist of only a play/pause button positioned in the center of the view. We can achieve this by creating exo_playback_control_view.xml file in the application's res/layout directory, containing:
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

  <ImageButton android:id="@id/exo_play"
      android:layout_width="100dp"
      android:layout_height="100dp"
      android:layout_gravity="center"
      android:background="#CC000000"
      style="@style/ExoMediaButton.Play"/>

  <ImageButton android:id="@id/exo_pause"
      android:layout_width="100dp"
      android:layout_height="100dp"
      android:layout_gravity="center"
      android:background="#CC000000"
      style="@style/ExoMediaButton.Pause"/>

</FrameLayout>

Note that in the layout @id/exo_play and @id/exo_pause are standard ids defined by the ExoPlayer library. Use of standard ids is required so that child views can be identified, bound to the player and updated in an appropriate way. A full list of the standard ids for each view can be found in the Javadoc for PlaybackControlView and SimpleExoPlayerView. Use of each standard id is optional.
https://medium.com/google-exoplayer/customizing-exoplayers-ui-components-728cf55ee07a

A: This will push the controls down to the bottom of the screen:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <com.google.android.exoplayer2.ui.PlayerView
        android:id="@+id/video_view"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:use_controller="false" />

    <com.google.android.exoplayer2.ui.PlayerControlView
        android:id="@+id/controls"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@id/video_view"
        app:show_timeout="0" />

</RelativeLayout>

Then in Java:
PlayerView videoView = findViewById(R.id.video_view);
PlayerControlView controls = findViewById(R.id.controls);
controls.setPlayer(videoView.getPlayer());

Edit: Modified my answer to suggestion from @RashimiGautam


text:
Q: php: call_user_func not working as expected i wrote some lines of code for dynamically executing a function like this:
$fn= "generatesomeHTML";
$html = call_user_func($fn);

the strange thing is - it works locally but not on my live server where the call_user_func returns null (for variable $html). any ideas what could be wrong?
thanks!

A: sorry was my fault .. the live version's function actually returned a zero value :(


text:
Q: Setting up React.js with Django failed I am currently learning React.js and I followed some tutorials on Youtube for React.js basics.
I didn't initially use npm run build(used it after I'm done coding the frontend) and I created my react frontend app inside my Django project.
When I am running npm start on cmd, react app works perfectly fine on localhost:3000.
enter image description here
But after I tried to run npm run build and done setting up, STATICFILES_DIRS, template_dirs, STATIC_URL and such, when I runserver on port:8000 which is default for django, all I can see is a white screen, I included console on the screenshot for error references:
empty django page with console
I even tried to put some text inside the body 'frontend/build/index.html' just to see if Django can access the template dirs, and the text put in shown on Django homepage localhost:8000.


text:
Q: How can I recover iCloud Calendar backup to iPhone 4? My calendar entries in my iPhone 4 have disappeared. I have no total backup - just calendar and contacts backup in iCloud. I only want to restore the calendar back to my iPhone 4. I already extracted the iCloud calendar backup into my PC.
Most websites only have instructions on how to restore the whole iCloud backup to the iPhone. What should I do?

A: If you previously synced your iPhone calendar with iCloud, you do not need to restore your iPhone. Just make sure you enable iCloud calendar sync by going to Settings → iCloud → Calendars → ON.

Always make sure to keep a safe backup of iPhone calendars and other data too in case you need to restore it later.


text:
Q: Newbie Question: Switch mode Power Supply Troubleshoot I have a small 12V 3.5A switch mode power supply that fails to provide any output.  I want to learn about switch mode power supplies so I thought I'd try to repair it.
Was hoping someone might be able to suggest what to check.
What I'v e done so far:
I reverse engineered some of the schematic, it looks like it's the pretty standard design based on the OB2262 PWM controller, with a TL431 voltage reference and feedback via an opto-isolator.
Symptoms and Steps
On power on, there seems to be an initial surge upto about 10V at the output, which rapidly dies away
I can measure 240V AC coming in, and 320V DC or so across the bulk capacitor, so no problems there.
I stuck the multi meter on frequency and looked at the signal on the FET driving the transformer, expecting to see about 200kHz or so, but nothing, so it doesn't look like it's oscillating.
I powered down, shorted the caps, then checked their in circuit capacitance and ESR, nothing seems wrong there.
I checked the diode voltage drops on the pair of Schotky diodes in the output circuit, and they seem to be as expected (voltage drop one way, OL the other).
Looked the board over for obvious shorts, broken tracks, or burnt components.  Nothing appears wrong.
Checked all the other diodes in circuit, none seem shorted.
Tried the following trick:  With the power off, applied 12V DC to the output, and checked the voltage divider across the output.  Under these conditions I checked the voltage between the 2 resistors of the voltage divider, I got about 0.7 volts.  My reasoning here is if I vary the voltage above and below 12V, the rated output of the PSU, I might be able to see some kind of signal being sent from the opto isolator, across to the live circuit.  As far as I can see there is none, although I don't really know what I should expect to see:  a constant voltage as a corrective signal (????) because there's no actual response to the voltage being greater or less than the rated 12V (my understanding here is sketchy I know).
I believe the TL431 and the opto-isolator rarely go bad, but I will check in powered down state as much as I can.
Any suggestions anyone?  How do these small wall wart switch mode PSUs normally fail?
I'm really hoping I don't have to replace the OB2262 chip, because it's so small and I don't have the facilities to do it.
Help would be greatly appreciated.


text:
Q: Detecting image events for non-transparent pixels only (drawHitFromCache) in Vue Konva So I'm basically trying to reproduce this behavior - detecting events for non-transparent pixels only (as seen when hovering over the lion) - but in vue-konva.
Here is the demo I'm working with. It basically just loads the image of lion and attaches the mouse events to it.
According to the doc, in order to have the event detection only for non-transparent pixels, I have to call methods cache() and drawHitFromCache() on the image object of lion.
At what point in code should these two methods be called in Vue? When I try to call them in the onload callback of the Image (see the commented lines 46-47 in the demo), I get the following errors:
Konva error: Width or height of caching configuration equals 0. Caching is ignored.

and
Cannot read property 'scene' of undefined

Thank you!

A: Vue may update properties of a component asynchronously. So when you are calling cache() you see Caching is ignored because a node is not updated yet, so Konva has no information about its size. To resolve the issue you may call cache in updated lifecycle method (when an image is loaded). Or you can cache the node on the next tick:
image.onload = () => {
  // set image only when it is loaded
  this.configImage.image = image;

  this.$nextTick(() => {
    this.$refs.staticImage.getNode().cache();
    this.$refs.staticImage.getNode().drawHitFromCache();
  });
};


text:
Q: Vectorizing 2D Convolutions in NumPy I know there are various optimized off-the-shelf functions available for performing 2D convolutions, but just for the sake of understanding, I am trying to implement my own 2D convolution function.
The following is what I done as of now:
    convoluted = []
    # TODO: Vectorize
    for i in range(0, M - m + 1):
        for j in range(0, N - n + 1):
            submatrix = x[i:i+m, j:j+n]
            convoluted.append(np.sum([submatrix*kernel]))
    convoluted = np.array(convoluted).reshape(M - m + 1, N - n + 1)

Note that x is the input image array, (M, N) is the shape of the input image, and (m, n) is the shape of the kernel used.
The 2 explicit for-loops are quite slow.
Is there any way to vectorize this? Any help is appreciated
(I know that python list comprehension can be used, at least for the inner loop, but I'm looking for a faster method, if any)

A: I think you are looking for this:
from skimage.util.shape import view_as_windows
sub_matrices = view_as_windows(x, (m,n), 1)
convoluted = np.einsum('ij,klij->kl',kernel,sub_matrices)

First line creates windows of kernel size from your original array. Second line is simple multiplication and addition (similar to the line in your for loop, more elegant to remove loops for it). The output of this and your code should be the same. If you are set to not use any of them, let us know your limitations to edit the post.
Another similar approach without using skimage package (using only numpy but slightly longer code) is here.

A: I build on Ehsan's answer to get the shortest answer that only uses Numpy:
windows = np.lib.stride_tricks.sliding_window_view(img, kernel.shape)
convolved_img = np.einsum('ij,klij->kl',kernel,windows)


text:
Q: Specify protocol of object in method parameters I want to pass an object to a method which should conform to a protocol, and be able to call the methods which are defined that protocol. However, I can't find any way of doing so. For example:
+ (void)prepareToBounceInView:(UIView*<PixelUI>)pixelUIView
    fromEdge:(PixelUIViewBounceEdge)edge;

The first parameter of the method is a UIView subclass which should conform to the PixelUI protocol, and the method should then be able to access properties and call methods defined in the protocol.
The only thing that worked was using id<PixelUI> as the type of the object, but then I can't access any of the properties or methods of the object itself, only those defined in the protocol; so I have to re-cast the object as (UIView*) when I need to treat it as the object it is, rather than as the delegate. This creates some ugly syntax, like this:
UIView *view = (UIView*)pixelUIView;
view.frame = pixelUIView.bounceBackFrame;

where view and pixelUIView are actually the same object, but have to be accessed using two different variable names.
If this is impossible then I will do as I have been doing and pass it in as id and then re-cast it. But if there is some syntax which will allow me to pass it in as its actual object while still specifying its protocol I'd love to know.

A: The order of the protocol and the star is important:
+ (void)prepareToBounceInView:(UIView<PixelUI> *)pixelUIView
    fromEdge:(PixelUIViewBounceEdge)edge;

With this no casts should be necessary.


text:
Q: Wrong formula specification in mformula/mlogit? Error in str2lang(x) : :2:0: unexpected end of input I'm trying to use the mlogit package in R in order to make a choice model on a panel dataset. For this, I have successfully specified the data in mlogit.data form. The y variable consists of TRUE / FALSE indicating the choice, the service variable consists of all choice options, and the id variable consists of all individuals who make the choices.
data <- mlogit.data(df, choice = "y",
                    shape = "long",
                    alt.var = "service",
                    id.var = "id")

Considering that I get the following error:
Error in str2lang(x) : <text>:2:0: unexpected end of input
1: . ~   . |
   ^

I'm assuming that I'm misspecifying my formula. I've tried to specify it in the following two manners, yet both result in the same error.
f1 <- mFormula(y ~ x1 + x2) # does not throw error

head(model.matrix(f1, data), 2) # throws the error

model1 <- mlogit(f1, data = data,
               rpar = c(x1 = "n",
                        x2 = "n"),
               panel = TRUE)  # throws the error

and
f2 <- y ~ x1 + x2 # does not throw the error

head(model.matrix(f2, data), 2) # does not throw error

model2 <- mlogit(f2, data = data,
               rpar = c(x1 = "n",
                        x2 = "n"),
               panel = TRUE)  # throws the error

The variables that I'm using in my formula are alternative-specific, meaning that for service s at period t, the variables have the same values.
Does anyone know what is causing the error? Thanks in advance!

A: I was running into the same error. First, the mlogit.data function is deprecated, so dfidx needs to be used to set up the format of the data. Secondly, when I was setting up my data using dfidx, I was departing from a data.table object and then when attempting to fit the model, I got the error you are asking about.
The way I solved it was by preparing the dfidx data using a data.frame object.


text:
Q: python code to read registry from  _winreg import *
areg=ConnectRegistry(None,HKEY_LOCAL_MACHINE)
akey=OpenKey(areg,"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall")
"""for i in range (259):"""
subkey=EnumKey(akey,0)
print subkey
demo=[]
demo=QueryValueEx(akey,"")
print demo

i am trying to obtain the value within the subkey ,what is wrong in this code ?

A: Try to replace this line:
akey=OpenKey(areg,"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall")

with
akey=OpenKey(areg,r"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall")


text:
Q: SaaS Multi-tenancy Applications: How is data import/export/backup being implemented? How are applications providing import / export (or backups) of data in SaaS based multi-tenancy applications, particularly single database designs?
Imports:
Keeping things simple I think basic imports are useful, ie CSV to a spec (or a way of providing a mapping between CSV columns and fields in the database.
Exports:
In single database designs I have seen XML exports and HTML (basic sitse generated) exports of data? I would assume that XML is a better option? How does one cater for relational data? Would you reference various things within XML and provide documentation of the relationships or let users figurethis out?
Are vendors providing an export/backup that can be imported back in/restored?
Your comments appreciated.

A: I don't know how it's done, but these are the possible scenarios:

*

*DB-per-customer

*schema-per-customer

*single-schema

Case 1 is trivial in terms of backup/restore (or import/export), case 2 is similar. I would venture a guess that these 2 are the most used approaches.
The third option makes export/import difficult, but not impossible. The basic idea is that a table holds data from all companies, but distinguishes the company by a foreign key. Export and import would require the same kind of ETL tool to be used because these actions require filtering by company ID. The export procedure takes a company as a parameter and runs the task for that company only. The dump would take the form of insert statements (like the one you can get with MySQL or PostgreSQL) or XML (like the one created by DDLUtils).
There are situations where the single-schema setup comes in handy, but I don't think multi-tenancy is one of them.


text:
Q: sqlcipher_export didn't export my tables I am using sqlciper with android to encrypt an existing sqlite db, and ran into a problem that the encrypted db didn't contain my tables, it only contains sqlite_master and android_metadata.
My original db looks like:
shell@umts_spyder:/sdcard $ sqlite3 d000000.dat
sqlite3 d000000.dat
SQLite version 3.7.4
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> select * from sqlite_master;
select * from sqlite_master;
table|android_metadata|android_metadata|2|CREATE TABLE android_metadata (locale TEXT)
table|PageData|PageData|3|CREATE TABLE PageData(File_Path TEXT NOT NULL UNIQUE, File_Content BLOB)
index|sqlite_autoindex_PageData_1|PageData|4|

I paste my encrypting code below, use empty key("") to open the plain db, if using null, NullPointerException raised(For both plain db I mentioned in the end of my post):
File plain = new File(mDbPath); /* /sdcard/d0000000.dat */
File encrypt = new File(plain.getParent(), "encrypted.dat");
encrypt.delete();
SQLiteDatabase db = SQLiteDatabase.openOrCreateDatabase(mDbPath, "", null);
String sql = String.format("ATTACH DATABASE '%s' AS encrypted KEY '%s'", encrypt.getPath(), mvKey.getText().toString()); // key is qqqqqqqq
db.execSQL(sql);
db.rawQuery("SELECT sqlcipher_export('encrypted')", null);
db.execSQL("DETACH DATABASE encrypted");

and below is the the code I used to test the encrypted db, there is only "android_metadata, " in the output, my table PageData lost. If I use "select * from PageData" directly, it raises no such table exception:
File file = new File(Environment.getExternalStorageDirectory(), "encrypted.dat");
if(!file.exists())
{
    mvBrowse.setText("not exist");
    return;
}
String key = mvKey.getText().toString();
SQLiteDatabase db = SQLiteDatabase.openOrCreateDatabase(file, key, null);
Cursor cursor = db.rawQuery("SELECT * FROM sqlite_master", null);
String str = new String();
while(cursor.moveToNext())
{
    str += cursor.getString(1)+", ";
}
mvBrowse.setText(str); // output is "android_metadata, "
cursor.close();
db.close();

The encrypting should work, because if I open encrypted.dat with empty("") key, it raise "file is encrypted or is not a database" exception, but I can read sqlite_master and android_metadata table with correct key.
I Confirmed the path I tested is the same one I write encryption to;
Tested creating plain db by sqlcipher, using empty key:
SQLiteDatabase db = SQLiteDatabase.openOrCreateDatabase(file, "", null); /* /sdcard/d000000.dat */
db.execSQL("CREATE TABLE PageData(File_Path TEXT NOT NULL UNIQUE, File_Content BLOB)");

As well as creating it by standard sqlite tools(SQLite Export Professional, and I didn't use BLOB field in this case, just only TEXT and INTEGER);
And tested with two API versions, "SQLCipher for Android v2.2.2" and "SQLCipher for Android v3.0.0".
I also tried to apply the Decrypt precedure as describled in http://sqlcipher.net/sqlcipher-api/ to a encrypted db.
All above got the same result. Will somebody help me? I beleive there is some tiny wrong inside but I can't figure it out.

A: Finally, I get fixed the problem, by learning from https://github.com/sqlcipher/sqlcipher-android-tests/blob/master/src/main/java/net/zetetic/tests/ImportUnencryptedDatabaseTest.java. (Thanks to @avlacatus, the link has been moved to: https://github.com/sqlcipher/sqlcipher-android-tests/blob/master/app/src/main/java/net/zetetic/tests/ImportUnencryptedDatabaseTest.java). The problem was, when executing the encrypting precedure, one must NOT use execSQL or rawQuery, but use a new introduced method "rawExecSQL. To be clear, the following code just work fine:
    String sql = String.format("ATTACH DATABASE '%s' AS encrypted KEY '%s'", encrypt.getPath(), mvKey.getText().toString());
    db.rawExecSQL(sql);
    db.rawExecSQL("SELECT sqlcipher_export('encrypted')");
    db.rawExecSQL("DETACH DATABASE encrypted");


text:
Q: How to skip any particular indexer from indexing when cron runs? I have configured cron (php bin/magento cron:run) which runs every minute. One of the tasks this cron job does is to update all indexers in Magento.
When the indexing is run via this cron job, I want to skip/exclude indexing for a particular indexer, let's say catalog_category_product from indexing and allow indexing for other indexers.
For this particular indexer, I will configure another cron (php bin/magento indexer:reindex catalog_category_product) which will run less frequent (not every minute).
So, how to exclude catalog_category_product from indexing when cron runs?


text:
Q: Magento 1.9: Maximum execution timeout after login Description:
After a customer logs into my shop, the script receives a stack overflow, execution timeout or exhausted memory size. But only at one store view (en_GB).
I guess it's a loop. I have only one magento-website with one store and a few store views. They are identical except for language/localization and each of them use the same templates etc. It doesn't matter which page I want to open in this store view (en_GB), it's always the same problem. If you log in to another store view and everything works and you change to this special store ID (en_GB), it's broken again until you delete all cookies. The status of the visitor is important: Without a logged-in user, the entire shop functions perfectly and you can change the shop IDs as many times as you want.
My setup:

*

*Ubuntu 18.04

*Nginx 1.14

*PHP 7.1

*HAProxy 1.88

*Magento 1.9.3.9 & PHP 7.2 PATCH

*Redis 4.0.9 & MariaDB 10.1.34 (on another server)

After the update of PHP and the increase of the memory limit, there are only exceptions to the maximum execution time. I guess after 30 seconds it's random which message is displayed.
Error Messages:
Fatal error: Maximum execution time of 30 seconds exceeded in /var/www/magento/app/code/core/Zend/Db/Select.php on line 1012[, 821, 1139]

or
Fatal error: Maximum execution time of 30 seconds exceeded in /var/www/magento/lib/Varien/Object.php on line 625

or
Fatal error: Maximum execution time of 30 seconds exceeded in /var/www/magento/lib/Varien/Simplexml/Element.php on line 195

or
Fatal error: Maximum execution time of 30 seconds exceeded in /var/www/magento/app/Mage.php on line 479

or
Fatal error: Maximum execution time of 30 seconds exceeded in /var/www/magento/lib/Zend/Locale/Math.php on line 244

or
Fatal error: Maximum execution time of 30 seconds exceeded in /var/www/magento/app/code/core/Mage/Sales/Model/Quote/Item/Abstract.php on line 255

or
Fatal error: Maximum execution time of 30 seconds exceeded in /var/www/magento/lib/Zend/Db/Statement/Pdo.php on line 431

There are no exceptions in the Magento logs. I don't know how to properly debug that. I've already deleted all caches and reindexed the database.
What I've already done:

*

*Delete all cookies and try again.

*Create new user in special store view (en_GB) and use its credentials. It works for this special store view (en_GB), but the change to another store view (e.g. de_DE) killed it again. It's the other way round.

*Activate and deactivate persistent shopping cart.

*Activate and deactivate session validation: Use SID in Frontend

*Change session storage from file to redis.

*Update SQL and PHP.

I've checked the general query log of SQL and found the following queries over and over again, maybe it's suspicious and give a hint. They occurred at the main page with a few widgets in a cms-page that are linking to the categories.
 LEFT JOIN `cataloginventory_stock_status` AS `status_table` ON main_table.product_id=status_table.product_id AND main_table.stock_id=status_table.stock_id AND status_table.website_id='1' WHERE (`main_table`.`stock_id` = '1') AND (`main_table`.`product_id` IN('47881'))
            6 Query SELECT `catalogrule_product_price`.`product_id`, `catalogrule_product_price`.`rule_price` FROM `catalogrule_product_price` WHERE (rule_date = '2018-09-28') AND (website_id = '1') AND (customer_group_id = '0') AND (product_id IN('47881'))
            6 Query SELECT `main_table`.* FROM `sales_flat_quote_address_item` AS `main_table` WHERE (`quote_address_id` = '78723')
            6 Query SELECT `main_table`.* FROM `sales_flat_quote_address_item` AS `main_table` WHERE (`quote_address_id` = '78724')
            6 Query SELECT `catalog_product_entity_group_price`.`value_id` AS `price_id`, `catalog_product_entity_group_price`.`website_id`, `catalog_product_entity_group_price`.`all_groups`, `catalog_product_entity_group_price`.`customer_group_id` AS `cust_group`, `catalog_product_entity_group_price`.`value` AS `price`, `catalog_product_entity_group_price`.`is_percent` FROM `catalog_product_entity_group_price` WHERE (entity_id='47881') AND (website_id = 0)
            6 Query SELECT `sales_flat_quote`.* FROM `sales_flat_quote` WHERE (`sales_flat_quote`.`entity_id`='39295') AND (store_id IN ('1', '4', '5', '3', '6', '7', '8', '9', '10', '2', '11', '12', '13', '15', '14')) AND (is_active = 1)
            6 Query SELECT `main_table`.* FROM `sales_flat_quote_address` AS `main_table` WHERE (`quote_id` = '39295')
            6 Query SELECT `main_table`.* FROM `sales_flat_quote_item` AS `main_table` WHERE (`quote_id` = '39295')
            6 Query SELECT `main_table`.* FROM `sales_flat_quote_item_option` AS `main_table` WHERE (`item_id` IN(81750))
            6 Query SELECT DISTINCT ea.attribute_code FROM `salesrule_product_attribute` AS `a`
 INNER JOIN `eav_attribute` AS `ea` ON ea.attribute_id = a.attribute_id
            6 Query SELECT `e`.* FROM `catalog_product_entity` AS `e` WHERE (`e`.`entity_id` IN(47881, 47881))
            6 Query SELECT `t_d`.`entity_id`, `t_d`.`attribute_id`, `t_d`.`value` AS `default_value`, `t_s`.`value` AS `store_value`, IF(t_s.value_id IS NULL, t_d.value, t_s.value) AS `value` FROM `catalog_product_entity_varchar` AS `t_d`
 LEFT JOIN `catalog_product_entity_varchar` AS `t_s` ON t_s.attribute_id = t_d.attribute_id AND t_s.entity_id = t_d.entity_id AND t_s.store_id = 2 WHERE (t_d.entity_type_id = 4) AND (t_d.entity_id IN (47881)) AND (t_d.attribute_id IN ('71', '98', '97', '87', '86', '118', '119', '122', '130')) AND (t_d.store_id = 0) UNION ALL SELECT `t_d`.`entity_id`, `t_d`.`attribute_id`, `t_d`.`value` AS `default_value`, `t_s`.`value` AS `store_value`, IF(t_s.value_id IS NULL, t_d.value, t_s.value) AS `value` FROM `catalog_product_entity_int` AS `t_d`
 LEFT JOIN `catalog_product_entity_int` AS `t_s` ON t_s.attribute_id = t_d.attribute_id AND t_s.entity_id = t_d.entity_id AND t_s.store_id = 2 WHERE (t_d.entity_type_id = 4) AND (t_d.entity_id IN (47881)) AND (t_d.attribute_id IN ('96', '102', '121', '100', '126', '123', '127', '125', '124', '128')) AND (t_d.store_id = 0) UNION ALL SELECT `t_d`.`entity_id`, `t_d`.`attribute_id`, `t_d`.`value` AS `default_value`, `t_s`.`value` AS `store_value`, IF(t_s.value_id IS NULL, t_d.value, t_s.value) AS `value` FROM `catalog_product_entity_decimal` AS `t_d`
 LEFT JOIN `catalog_product_entity_decimal` AS `t_s` ON t_s.attribute_id = t_d.attribute_id AND t_s.entity_id = t_d.entity_id AND t_s.store_id = 2 WHERE (t_d.entity_type_id = 4) AND (t_d.entity_id IN (47881)) AND (t_d.attribute_id IN ('75', '80', '76', '120')) AND (t_d.store_id = 0) UNION ALL SELECT `t_d`.`entity_id`, `t_d`.`attribute_id`, `t_d`.`value` AS `default_value`, `t_s`.`value` AS `store_value`, IF(t_s.value_id IS NULL, t_d.value, t_s.value) AS `value` FROM `catalog_product_entity_datetime` AS `t_d`
 LEFT JOIN `catalog_product_entity_datetime` AS `t_s` ON t_s.attribute_id = t_d.attribute_id AND t_s.entity_id = t_d.entity_id AND t_s.store_id = 2 WHERE (t_d.entity_type_id = 4) AND (t_d.entity_id IN (47881)) AND (t_d.attribute_id IN ('77', '78')) AND (t_d.store_id = 0) UNION ALL SELECT `t_d`.`entity_id`, `t_d`.`attribute_id`, `t_d`.`value` AS `default_value`, `t_s`.`value` AS `store_value`, IF(t_s.value_id IS NULL, t_d.value, t_s.value) AS `value` FROM `catalog_product_entity_text` AS `t_d`
 LEFT JOIN `catalog_product_entity_text` AS `t_s` ON t_s.attribute_id = t_d.attribute_id AND t_s.entity_id = t_d.entity_id AND t_s.store_id = 2 WHERE (t_d.entity_type_id = 4) AND (t_d.entity_id IN (47881)) AND (t_d.attribute_id IN ('101')) AND (t_d.store_id = 0)
            6 Query SELECT `cataloginventory_stock_status`.`product_id`, `cataloginventory_stock_status`.`stock_status` FROM `cataloginventory_stock_status` WHERE (product_id IN('47881')) AND (stock_id=1) AND (website_id=1)
            6 Query SELECT `main_table`.*, `default_option_title`.`title` AS `default_title`, `store_option_title`.`title` AS `store_title`, IF(store_option_title.title IS NULL, default_option_title.title, store_option_title.title) AS `title`, `default_option_price`.`price` AS `default_price`, `default_option_price`.`price_type` AS `default_price_type`, `store_option_price`.`price` AS `store_price`, `store_option_price`.`price_type` AS `store_price_type`, IF(store_option_price.price IS NULL, default_option_price.price, store_option_price.price) AS `price`, IF(store_option_price.price_type IS NULL, default_option_price.price_type, store_option_price.price_type) AS `price_type` FROM `catalog_product_option` AS `main_table`
 INNER JOIN `catalog_product_option_title` AS `default_option_title` ON default_option_title.option_id = main_table.option_id
 LEFT JOIN `catalog_product_option_title` AS `store_option_title` ON store_option_title.option_id = main_table.option_id AND store_option_title.store_id = '2'
 LEFT JOIN `catalog_product_option_price` AS `default_option_price` ON default_option_price.option_id = main_table.option_id AND default_option_price.store_id = 0
 LEFT JOIN `catalog_product_option_price` AS `store_option_price` ON store_option_price.option_id = main_table.option_id AND store_option_price.store_id = '2' WHERE (default_option_title.store_id = 0) AND (`product_id` IN('47881'))
            6 Query SELECT `core_url_rewrite`.`product_id`, `core_url_rewrite`.`request_path` FROM `core_url_rewrite` WHERE (store_id = 2) AND (is_system = 1) AND (category_id = 0 OR category_id IS NULL) AND (product_id IN('47881')) ORDER BY `category_id` DESC
            6 Query SELECT `catalog_product_entity_tier_price`.`value_id` AS `price_id`, `catalog_product_entity_tier_price`.`website_id`, `catalog_product_entity_tier_price`.`all_groups`, `catalog_product_entity_tier_price`.`customer_group_id` AS `cust_group`, `catalog_product_entity_tier_price`.`qty` AS `price_qty`, `catalog_product_entity_tier_price`.`value` AS `price`, `catalog_product_entity_tier_price`.`entity_id` AS `product_id` FROM `catalog_product_entity_tier_price` WHERE (entity_id IN('47881')) AND (website_id = 0) ORDER BY `entity_id` ASC, `qty` ASC
            6 Query SELECT `main_table`.*, `cp_table`.`type_id`, `status_table`.`stock_status` FROM `cataloginventory_stock_item` AS `main_table`
 INNER JOIN `catalog_product_entity` AS `cp_table` ON main_table.product_id = cp_table.entity_id
 LEFT JOIN `cataloginventory_stock_status` AS `status_table` ON main_table.product_id=status_table.product_id AND main_table.stock_id=status_table.stock_id AND status_table.website_id='1' WHERE (`main_table`.`stock_id` = '1') AND (`main_table`.`product_id` IN('47881'))
            6 Query SELECT `catalogrule_product_price`.`product_id`, `catalogrule_product_price`.`rule_price` FROM `catalogrule_product_price` WHERE (rule_date = '2018-09-28') AND (website_id = '1') AND (customer_group_id = '0') AND (product_id IN('47881'))
            6 Query SELECT `main_table`.* FROM `sales_flat_quote_address_item` AS `main_table` WHERE (`quote_address_id` = '78723')
If you need more information, please let me know and thank you in advance!

Edit (24.10.2018):
After re-generating the "en_gb" store view, I saw this loop behavior when changing the currency to Pounds in the configuration. When I use Euro as my default currency in this store view, everything works fine. Any ideas how i can debug this?


text:
Q: GPG can't check signature I was trying to recompile and rebuild libevent2 source from oneiric on my natty server and I had a small error with gpg not being able to check signature
# dpkg-source -x libevent_2.0.12-stable-1.dsc
gpgv: Signature made Fri Jun 17 07:12:50 2011 PDT using DSA key ID 7ADF9466
gpgv: Can't check signature: public key not found
dpkg-source: warning: failed to verify signature on ./libevent_2.0.12-stable-1.dsc

Any idea how to fix this warning?

A: You should import the key to local keyring with the following command:
gpg --keyserver keyserver.ubuntu.com --recv-keys 7ADF9466

Then, try again the command.

A: I believe the conventional solution is to install the GnuPG keys of Debian Developers package:
sudo apt-get install debian-keyring

A: First of all, you should import the key to local keyring as @enzotib instructed:
gpg --keyserver keyserver.ubuntu.com --recv-keys 7ADF9466

Then export the key to your local trustedkeys to make it trusted:
gpg --no-default-keyring -a --export 7ADF9466 | gpg --no-default-keyring --keyring ~/.gnupg/trustedkeys.gpg --import -


text:
Q: Finding the depth of nesting in a macro call Is there a general way to find the depth of a macro evaluation? For example, consider the following script,
\documentclass{beamer}
\usepackage{mathtools}
\usepackage{calc}

\begin{document}

\begin{frame}
  \newcommand*{\ofSize}[2]{\hphantom{####2}\llap{####1}}
  x \alt<1>{\ofSize{apples}{oranges}}{oranges} \uncover<1-2>{done.}

\end{frame}

\end{document}

I wanted to alternate between two expressions so that it would not cause surrounding text to move around during animations, with a more general solution then that given in Animated equation in Beamer. As you can see, I needed to escape the first argument, #1, three more times (####1) to get this to work.
The process I used was arbitrary; I just added # till it stopped giving me an error. Clearly, this could fail with horrendous side-effects if #1 is a meaningful expansion in a "deeper" nested macro level. Is there a best practice / methodology when writing such commands?

A: The details are pretty involved. But basically beamer reads the contents of a frame environment as an argument and this process reduces a pair of ## into one #; but now your \newcommand is given in the argument to another command, so the # marks need to be doubled.
The pairing means that you need four # characters to mean one of them.
The solution is to do it in the preamble.
\documentclass{beamer}
\usepackage{mathtools}
\usepackage{calc}

\newcommand*{\ofSize}[2]{\leavevmode\hphantom{#2}\llap{#1}}

\begin{document}

\begin{frame}

x \alt<1>{\ofSize{apples}{oranges}}{oranges} \uncover<1-2>{done.}

\end{frame}

\end{document}

Don't forget the initial \leavevmode, because \hphantom doesn't start a paragraph, so if \ofSize is not preceded, like in the example application, by something that starts a paragraph, you wouldn't get the expected result.

A: egreg has already explained pretty well what is happening when beamer processes a frame. Besides moving the macro definition out of the frame environment, there is also the alternative to mark the frame as [fragile]:
\documentclass{beamer}
\usepackage{mathtools}
\usepackage{calc}

\begin{document}

\begin{frame}[fragile]

  \newcommand*{\ofSize}[2]{\leavevmode\hphantom{#2}\llap{#1}}

x \alt<1>{\ofSize{apples}{oranges}}{oranges} \uncover<1-2>{done.}

\end{frame}

\end{document}

With fragile, beamer processes the frame in a different way: Basically, it gobbles the content and writes it to an external file (with the extension .vrb). I then passes the file as argument to the "engine" macro, which read it back as many time as needed. Thereby, all kind of problems related to macro arguments (verbatim material, for instance), are avoided.
The drawback is a slightly longer processing time. The advantage is that you can keep macro definitions local to a frame where appropriate. I tend to do this a lot, as it reduces the risk of forgetting some macro when reusing a frame in another presentation.


text:
Q: Autohotkey Mapping Modifiers I can't use arrow keys from my keyboard so I mapped 1234 to be the arrow keys like that:
*!^1::
   Send, {Left down}{Left up}
Return

*!^2::
   Send, {Down down}{Down up}
Return

*!^3::
   Send, {Up down}{Up up}
Return

*!^4::
   Send, {Right down}{Right up}
Return

Now my problem is that in some programs the arrow keys pressed with the shift modifier is associated to a function and with the current settings, when I press Ctrl+Alt+Shift+1 it still outputs me the associated arrow key without considering the 'Shift' modifier.
Do you know how could I solve the problem?
Thanks.

A: You can just add a list of commands that already includes the shift key, like this:
*+!^1::
   Send, {Shift down}{Left down}{Left up}{Shift up}
Return

*+!^2::
   Send, {Shift down}{Down down}{Down up}{Shift up}
Return

*+!^3::
   Send, {Shift down}{Up down}{Up up}{Shift up}
Return

*+!^4::
   Send, {Shift down}{Right down}{Right up}{Shift up}
Return


text:
Q: How to move up text fields in a scroll view when on focus for input I have the following activity as rendered from a 320 x 480 low-density screen (don't mind the black strip on the right, it's a problem with the screen capture).

The EditTexts are enclosed in a ScrollView--there's six of them, actually. The sign up button shares a LinearLayout with the ScrollView via weight measurement, while everything else is positioned via a RelativeLayout. When I tap on the "E-mail" text field (the fourth one), this is what shows:

My question is, how can I make the parent RelativeLayout move up and not just the ScrollView to make the e-mail text field more visible? Also, the hint of the sign-up button there is quite ugly. Is there any way I can avoid that? Here's the XML code for the layout.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/bg_320x480">

    <TextView android:id="@+id/signup_logo_txt"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="#0a6698"
        android:textColor="#ff7f00"
        android:text="Blackened App Name"
        android:textStyle="bold"
        android:textSize="10pt"
        android:gravity="center"
        android:padding="8dp"
        />

    <ImageView android:id="@+id/signup_icons_ghost_img"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:src="@drawable/icons_ghost_320x112"
        android:layout_below="@id/signup_logo_txt"
        android:contentDescription="lalalala"
        android:layout_marginTop="-21dp"
        />

    <TextView android:id="@+id/signup_tagline_txt"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="The easiest way to find a mobile plan that best suits how you use your phone."
        android:textColor="#000"
        android:textSize="5pt"
        android:gravity="center"
        android:layout_below="@id/signup_logo_txt"
        android:layout_marginTop="10dp"
        />

    <TextView android:id="@+id/signup_getstarted_txt"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="Sign up and let's get started!"
        android:textColor="#0a6998"
        android:textSize="6pt"
        android:textStyle="bold"
        android:gravity="center"
        android:layout_below="@id/signup_tagline_txt"
        android:layout_marginTop="6dp"
        />

    <LinearLayout android:orientation="vertical"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:weightSum="1.0"
        android:layout_marginLeft="10dp"
        android:layout_marginRight="10dp"
        android:layout_below="@id/signup_getstarted_txt"
        >
        <ScrollView android:id="@+id/signup_fields_view"
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight=".8">
            <LinearLayout android:orientation="vertical"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                >
                <EditText android:id="@+id/signup_name_fld"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:singleLine="true"
                    android:hint="Navn"
                    android:layout_marginTop="5dp"
                    />

                <EditText android:id="@+id/signup_carrier_fld"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:singleLine="true"
                    android:hint="Nuvaerende mobilselskab"
                    android:layout_marginTop="3dp"
                    />

                <EditText android:id="@+id/signup_plan_fld"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:singleLine="true"
                    android:hint="Mobilforbrug i kroner"
                    android:layout_marginTop="3dp"
                    />

                <EditText android:id="@+id/signup_email_fld"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:singleLine="true"
                    android:hint="E-mail"
                    android:layout_marginTop="3dp"
                    />

                <EditText android:id="@+id/signup_verify_email_fld"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:singleLine="true"
                    android:hint="Bekraeft e-mail"
                    android:layout_marginTop="3dp"
                    />

                <EditText android:id="@+id/signup_mobile_number_fld"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:singleLine="true"
                    android:hint="Mobilnummer"
                    android:layout_marginTop="3dp"
                    />
            </LinearLayout>
        </ScrollView>

        <Button android:id="@+id/signup_signup_btn"
            android:layout_width="wrap_content"
            android:layout_height="0dp"
            android:layout_weight=".2"
            android:text="SIGN UP"
            android:textColor="#fff"
            android:layout_gravity="center"
            android:layout_marginBottom="8dp"
            />
    </LinearLayout>

</RelativeLayout>

A: i thing you not set adjust pan.set android:windowSoftInputMode="adjustPan" in Activity in Manifest file