Suppress error message when reading user input

Question: I have a Linux script that reads user input like this:
read -er user_input

This might fail as -e is supported in bash (perhaps some other shells too), but will fail with e.g. zsh. I came up with this:
{
    # This may fail. The "e" option is a bash extension that allows user to
    # use arrows to navigate the input. If it fails, we fall back to classic
    # read and ignore the error
    read -er user_input 2> /dev/null
} ||
{
    read -r user_input
}

The idea was that if read -er user_input fails, we fall back to what always works. I expected that 2> /dev/null will eat the error message that stems from lack of support for that option (Illegal option -e). What happens though is that user input is not shown either (user does not see what she types).
How to correctly handle this? Or maybe it's safe to assume e exists in bash only and I should check for what shell we're running? If so, what's the best way to check it?
Comment: As you've noticed, stderr is used for prompts. And yes, personally, I _would_ check the shell. `case $BASH_VERSION in '') do the portable thing;; *) do the bash-only thing;; esac`
Comment: I believe my answer describes that above. (Nothing surprising about stderr -- think about how useless it would be if it were stdout! you couldn't pipe from any program that communicates with the user!)
Comment: (...also, POSIX describes stderr as used for "diagnostic output", and status information -- like "waiting for input", or other logging -- is diagnostic in nature; it's not what the program exists to create, but lets operators know what's going on).
Comment: @CharlesDuffy Sorry, I removed my comment as you have added a viable option. Do you think `e` is bash-specific? I didn't want to exclude other shells that support that option.
Comment: `-e`'s interpretation as meaning that readline should be used to allow cursor interaction is _definitely_ bash-specific (readline and bash have the same author, and because readline is GPLed, shells under MIT or BSD licenses don't use it). Could there be another shell that uses it to do a similar prompt with `editline` instead of `readline`? I couldn't write off the possibility.
Comment: That said, in general, scripts should have a shebang that forces them to be executed by the specific shell that they're tested to work with; whereas if something is meant to be sourced rather than executed, it should have a file extension that corresponds with its actual requirements (`.zsh` for zsh-only code, `.bash` for bash-only code, `.sh` for code that makes no assumptions not guaranteed by the POSIX sh standard, etc); that way you can offer a baseline-POSIX version of your shell library, and also bash- or zsh-optimized versions.
Comment: @CharlesDuffy Thanks for the detailed explanation, great answer! You could consider adding to it also information why my approach didn't work (the `stderr` used for prompts,  I had no idea).
Answer: The easiest way to tell if read -e is accepted by your current shell (assuming you're willing to take the risk of it meaning something completely different to that shell) is to try it and see:
if printf '\n' | read -e >/dev/null 2>&1; then
    read -er user_input
else
    read -r user_input
fi

As to why redirect stderr suppresses prompting:
POSIX specifies stderr to be used for "diagnostic output", a category that is generally read to include logging, status, and prompting (since the status of a running program -- such as waiting-for-input -- is generally part of understanding its current state and what needs to be done to allow it to successfully complete). Keeping this information away from stdout lets programs communicate with the user even if their output might be directed into a pipeline or away to a file.


Registering a Composite Control

Question: I am learning custom controls and just finished my first one. The problem is that I am struggling to register it in my web config and have the compiler recognize it. Right now this results in a YSOD about the reference to the control.
note: exact error - Error Unknown server tag 'cc:LblTextBox'.
Thank you!
Web Config
//..
//..
     <pages>
       <controls>
         <add tagPrefix="cc" namespace="Controls.Server"/>
       </controls>
     </pages>
</system.web>

The control code-behind
namespace Controls.Server
{
    public class LblTextBox : CompositeControl
    {
       //...
    }
}

mark-up
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="ControlsMain.aspx.cs" Inherits="Pages_ControlsMain" Trace="true" %>

 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

     <title>Controls Area</title>

    <form id="form1" runat="server">

          First attempt at a simple composite control

         <cc:LblTextBox ID="ccLblTbHybrid" runat="server" LabelText="Name:" />

   </form>

Answer: Try registering your composite control at the top of the page:
<%@ Register cc="myControls" Namespace="Controls.Server" %>

You might also try specifying the assembly in your web.config:
<add tagPrefix="cc" namespace="Controls.Server" assembly="whatever"/>

Comment: The assembly raises another issue. I noticed than when I created new folders and placed code into them, they did not auto generate the namespaces. I had to manually assign one. Normally I have never had to do that. Is it possible that I don't have an assembly name and that is why it cannot reference the namespace within the assembly? Just tossing ideas
Comment: another note, the project is a ASP.net Web Site project. As I understand, the assembly dlls are not precompiled ... will this affect how I register the namespace?
Comment: Your answer was partially correct! I posted my full solution.
Answer: The issue stemmed from setting up the project as an ASP.Net Web Site
This has a drawback because the name of your assembly is not known till runtime.
I recreated the project as a ASP.Net Web Application, allowing for procompilation of the DLLs .... thus giving me the ability to give the project a namespace.
I then added abe's suggestion into the entry and all is working now
<add tagPrefix="cc" namespace="Controls.Server" assembly="DevLore"/>

Registering a Composite Control


How to store values retrieved from a loop in different variables in Python?

Question: Just a quick question.
Suppose, I have a simple for-loop like
for i in range(1,11):
    x = raw_input()

and I want to store all the values of x that I will be getting throughout the loop in different variables such that I can use all these different variables later on when the loop is over.
Comment: Why are all of the valid answers here getting downvotes?
Comment: Even I can't understand that. I'm not doing it.
Comment: Every downvotes are removed, except the one in my answer. Can't just figure out what have I done wrong. Poor funny downvoter, didn't have time to explain the reason :D
Comment: Looks like the downvotes seem to have now been removed, meh, I'm not complaining.
Comment: is raw_input() function you've created?
Answer: Create a list before the loop and store x in the list as you iterate:
l=[]
for i in range(1,11):
    x = raw_input()
    l.append(x)
print(l)

Comment: It worked in my problem here: https://stackoverflow.com/questions/71572659/opening-muli-tiff-files-in-a-directory-and-applying-all-same-steps/71584517#71584517 Thank you.
Answer: You can store each input in a list, then access them later when you want.
inputs = []
for i in range(1,11);
    x = raw_input()
    inputs.append(x)

# print all inputs
for inp in inputs:
    print(inp)

# Access a specific input
print(inp[0])
print(inp[1])

Answer: You can form a list with them.
your_list = [raw_input() for _ in range(1, 11)]

To print the list, do:
print your_list

To iterate through the list, do:
for i in your_list:
    #do_something

Comment: Even I don't get why such helpful responses are getting a down vote.
Answer: using Python 3:
m=[]
for i in range(1,11):
    m.append(i**2) #your expression
print(m)

#or
m=[i**2 for i in range(1,11)]
print(m)


How to redirect to content if view have 1 result?

Question: Views page show content.
How to redirect to content page if views has only one result?
Answer:
In your theme's themename.theme file add:
At the very top add:
use Drupal\views\ViewExecutable;
use Symfony\Component\HttpFoundation\RedirectResponse;

Then add:
/*
 * Implements hook_views_pre_render()
 */
function THEMENAME_views_pre_render(ViewExecutable $view) {
    if($view->id() == "view_name" && $view->current_display == 'view_machine_name') {
      if (!empty($view->result) && count($view->result) == 1) {
        $url = $view->result[0]->_entity->toUrl()->toString();
        $response = new RedirectResponse($url);
        $response->send();
      }
    }
}

Clear the cache so changes kick in.

my_module/src/Controller/ViewPageController.php
namespace Drupal\my_module\Controller;

use Drupal\Core\Cache\CacheableRedirectResponse;
use Drupal\Core\Controller\ControllerBase;
use Drupal\views\Views;

/**
 * Defines HelloController class.
 */
class ViewPageController extends ControllerBase {

  public function content() {

    $view = Views::getView('view_name');
    $view->setDisplay('view_machine_name');
    $view->execute();

    if (!empty($view->result) && count($view->result) == 1) {

      $url = $view->result[0]->_entity->toUrl()->toString(TRUE);
      $response = new CacheableRedirectResponse($url->getGeneratedUrl());
      $response->getCacheableMetadata()->addCacheTags($view->getCacheTags());
      $response->addCacheableDependency($url);
      return $response;

    }
    else {

      return [
        '#type' => 'view',
        '#name' => 'view_name',
        '#view' => $view,
        '#display_id' => 'view_machine_name',
        '#embed' => TRUE,
        '#cache' => $view->getCacheTags(),
      ];

    }

  }

}

This is the view_machine_name.
Comment: You need to clear the cache every time ;-). It's never a good idea to send a response instead of returning it. But for this use case when a redirect depends on database content I think a custom controller which either returns the view or a cacheable redirect response containing the correct cache metadata would be the best approach.
Comment: Yes, but the redirect needs to get invalidated, too, when the view result is no longer 1. The problem with sending is you have to responses, one you've sent and one which is getting cached, which makes this quite unpredictable what happens.
Comment: No, `$response->addCacheableDependency($url);` doesn't work when this is already applied.
Comment: @4k4 `You need to clear the cache every time` Doesn't the view get invalidated via cache tag? Or are you referring to when adding a new hook?
Comment: @4k4 you're right, I could've sworn it worked for me without having to clear the cache, but now it won't work unless I clear the cache. Oh I see now, I prob got a false positive due to having multiple view blocks on the page. I didn't do a view_name conditional.
Comment: @4k4 I thought of custom controller at first, but was too lazy for that. So I tried to see if there was quicker alternative.
Comment: @4k4 this seems to work fine, tho I am not sure if that's the proper way to return the response, as I'm suppose to be returning an array. I couldn't find a [RenderElement](https://api.drupal.org/api/drupal/elements) that would fit the bill for this.
Comment: Yes, a controller can return a response, but use a CacheableRedirectResponse and add the cache tags: `$response->getCacheableMetadata()->addCacheTags($view->getCacheTags());`. The
OP might also need to add more cache data, the question doesn't provide any details on which the result might depend on.
Comment: @4k4 `getCacheableMetadata()` is not a valid method for [RedirectResponse](https://api.drupal.org/api/drupal/vendor%21symfony%21http-foundation%21RedirectResponse.php/class/RedirectResponse/8.2.x). Anyhow, I did a `$response->isCacheable();` and it came back false, so we good.
Comment: The problem is that Drupal still caches the uncacheable RedirectResponse, then without cache tags. Only if you use [CacheableRedirectResponse](https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Cache%21CacheableRedirectResponse.php/class/CacheableRedirectResponse/8.7.x) and add the cache tags it will get invalidated when the content changes in the database.
Comment: @4k4 Using CacheableRedirectResponse [gave an error](https://i.stack.imgur.com/nXr2z.png) `The controller result claims to be providing relevant cache metadata, but leaked metadata was detected. Please ensure you are not rendering content too early. Returned object class: Drupal\Core\Cache\CacheableMetadata. in Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber...` clearing the cache does not fix it.
Comment: Yes, this is another tricky one. When you convert a URL to a string use `toString(TRUE)` and add the resulting cache dependency to the response as well, see https://drupal.stackexchange.com/questions/225956/cache-controller-with-json-response
Comment: @4k4 when using `TRUE` you need `->getGeneratedUrl();` after it; otherwise, it throws an error. Cheers!
Comment: @NoSssweat I just reverted that edit (you missed the line immediately after, which uses `$generated_url->getGeneratedUrl()`)
Comment: @4k4 sorry I'm a bit confused, 6 am here, you're talking about your [other answer](https://drupal.stackexchange.com/a/225963/27710) that Clive reverted, right? OR are you saying I don't need that line here?
Comment: You need the line, but for $url without getGeneratedUrl() applied. I'll edit the answer.
Comment: @4k4 ha, I fee like an idiot, time to go to bed.
Answer: There's a LOT better way. Use hook_views_post_render() instead. See my comment here.
and the documentation at views.api.php
/**
 * Post-process any render data.
 *
 * The module or theme may add, modify or remove elements in $output after
 * rendering.
 *
 * If a module wishes to act on the rendered HTML of the view rather than the
 * structured content array, it may use this hook to add a #post_render
 * callback:
 * @code
 * // The object must implement \Drupal\Core\Security\TrustedCallbackInterface.
 * $output['#post_render'][] = '\Drupal\my_module\View::postRender';
 * @endcode
 *
 * See \Drupal\Core\Render\RendererInterface::render() for #post_render
 * documentation.
 *
 * Alternatively, it could also implement hook_preprocess_HOOK() for
 * the particular view template, if there is one.
 *
 * @param \Drupal\views\ViewExecutable $view
 *   The view object being processed.
 * @param array $output
 *   A structured content array representing the view output. The given array
 *   depends on the style plugin and can be either a render array or an array of
 *   render arrays.
 * @param \Drupal\views\Plugin\views\cache\CachePluginBase $cache
 *   The cache settings.
 *
 * @see \Drupal\views\ViewExecutable
 */
function hook_views_post_render(ViewExecutable $view, array &$output, CachePluginBase $cache) {

  // When using full pager, disable any time-based caching if there are fewer
  // than 10 results.
  if ($view->pager instanceof Drupal\views\Plugin\views\pager\Full && $cache instanceof Drupal\views\Plugin\views\cache\Time && count($view->result) options['results_lifespan'] = 0;
    $cache->options['output_lifespan'] = 0;
  }
}


MongoDB unwind in find()? and Performance better in find() queries?

Question: I have this aggregate query, which takes really long to get results and I only need the Aggregation framework because of the $unwind parameter. To be specific I have to query things that are in an array. How can I rewrite this aggregation query into a find query and do you think performance would be better with find?
db.cms.aggregate([{"$unwind":"$values"},
                       {"$match": {"values.timestamp":{"$exists":1}}},
                       {"$match": {"values.sensor":"V1"}},
                       {"$match": {"values.timestamp":{"$gte":"2018-02-07 14:00:16.163","$lte":"2018-02-07 14:00:16.163"}}}] )

The documents in the collection look like this
_id" : ObjectId("5a8ac17569191602538b65d2"),

"values" : [
    {
        "sensor" : "B",
        "unit" : "mm/s2",
        "timestamp": "2018-02-07 14:00:16.163"

    },
    {
        "sensor" : "Bp",
        "unit" : "mm/s2",
        "timestamp": "2018-02-07 14:00:16.163"
    },
    {
        "sensor" : "Bt",
        "unit" : "mm/s2",
        "timestamp": "2018-02-07 14:00:16.163"
    },
    {
        "sensor" : "V1",
        "timestamp" : "2018-02-07 14:00:16.163",
        "unit" : "V"

    }]}

Comment: I dk if you will have a better performance without the aggregation but you should take a look at the performance of the query and understand why it's taking to long. Take a look at the explain() function
Comment: @Graciano I already took a look at explain() and it uses no Index although I created a compound index on "values.timestamp" ,"values.sensor" and Single Indexes on the two of them. Now I guess that maybe the unwind with aggregation doesnt really work with indices
Answer: If all you need is filtering out, simply use the $filter operator:
db.cms.aggregate([
{
    $project: {
        values : {
            $filter: {
                input: "$values",
                as: "value",
                cond: {
                    $and: [
                        { $ifNull: [ "$$value.type", false ] },
                        { $eq: [ "$$value.sensor", "V1" ] },
                        { $eq: [ "$$value.timestamp", "2018-02-07 14:00:16.163" ] },
                    ]
                }
            }
        }
    }
}
])

By the way, the cond field of the aggregational $filter operator requires an expression that resolves to a boolean value. We cannot use
the $exists nor any query operator, and its aggregational equivalent is the $ifNull operator.


Techniques to return aggressive tennis serves?

Question: I injured my forearm when I tried to return a fast aggressive serve at about 200km/h with basic forehand grip and backswing: the hit can extremely damaging to your ulnar nerve more here (particularly if you are too slow to react). I realised in my last tournament that I can return such serves easily with basic volley grip: no topspin but the ball reflect without much effort safely on the other side. If you have basic forehand grip, you need to be very quick and it is very very exhaustive to your forearm. Currently, my goal is to learn the safest technique to play against aggressive players. Now simple question:

Techniques to return very aggressive serves?

Related questions

I. How does the volley in serve-returning compares to the basic volley near net?

I. Same footwork in the volley-returning serve as in the basic volley near the net?

II. What is the safest technique to return very aggressive serves?
Answer: I recently had a game against a hard server (at my level I very rarely come across) which resulted in a sore arm (particulary elbow).
Becuase of the reduce time to react I was using more of my muscles to get the racquet head back and then through into the ball. If I did not time it perfectly the jarring would cause pain.
There are a couple of things that I found that helped. (some of these might be obvious but wanted to list them anyway)

Relax the grip and arm as part of the server's early serve motion. Any tension can jar if not timed correctly. Look at this video of Victoria Azarenka
Stand a little further back from the baseline. Although this may open up wider serves the little bit of extra time can help. You can do this early on the game and work your way in when you are warmer and more confident on the pace of the ball.
Reduce the back swing. Pros such as Federer do this a lot but they have exceptional timing. Try to not to bring the head back as far as you would with a ground stroke. You may loose power on the return but can be effective to at least get the ball back to your opponent (especially if you can get it deep).
Use the pace of the serve. Alot of pros seem to stab the ball back on the backhand side rather than a full topspin return. With the pace on the ball you do not have to try too hard to get the ball back. It tends to float to the baseline but can give you time to get back into position. A hard server sometimes wins the point simply by having you out of position from the return of serve
Stay on your toes and bounce a little at point of contact the server has on the ball. To help with all the above, being able to shift weight to the correct side as early as you can will help with the swing and timing.

I believe that injury off the serve can happen from being too tense and mistiming the ball (because you are rushed into a shot). Mitigating these 2 should reduce injury, as I have found.
Answer: During my college days when a competitive match came, I always encountered big servers because it throw of your balance and you can kill the rally by simple one-two punch, I will teach you my technique on how to counter and use your opponents strength and can do return ace.
First is early in the game, try to figure your opponent's habit during serving and return every serve with slice to enemy's backhand side. This has worked every time because of service follow-through and so the return from their backhand is not too strong.
So once I figure out his habits, I try to do half swings during his service and I'm a kind of player who has erratic return and unpredictable by slamming the ball in the inside out for a winner. And for you, by using half swings and place them in his weak side or it depends on you, move back from the baseline and don't forget his habits and its probability where his serve would land, with this you can dominate the match.
In learning this style, I watched Roger Federer vs Andy Roddick matches in order for me to figure out how to counter big servers.


Como posso pegar a data e hora, em angular e mandar pro BD?

Question: Encontrei esse código:
função em angular pra pegar data e hora
Testei ele e funciona legal.
Mas preciso pegar essa data e mandar pro banco, junto com outros dados. Como posso fazer isso?
Meu código está assim:
<code>$scope.enviarMsg = function (mensagem) {

    function Time($scope){
        $scope.date = new Date();
    }
    var dte = Time($scope);

    var enviaMsg = {
        mensagem: mensagem,
        idUsuario: $window.localStorage.getItem('idUsuario'),
        idCep: $window.localStorage.getItem('idCep'),
        nome: $window.localStorage.getItem('nome'),
        date: dte
    }

    $http.post("http://www.vigilantescomunitarios.com/www/php/enviaMsgLogra.php", enviaMsg).success(function (data){

        console.log(data);
        pegaMsgsLogra();
        $scope.mensagem = {
          msg: ""
        }

    });
}
</code>
Print do console
Comment: Tente fazer esse teste: `date: new Date();` ao invés de `date: dte`
Comment: Obrigado pela ajuda, mas já consegui com esse site:
http://momentjs.com/
Comment: Vc está atribuindo o `dte` a date, isso não está sendo enviado no JSON?
Comment: Não @Techies, não está sendo enviado para o JSON. Veja na imagem que postei.
Comment: Não estou vendo a imagem.
Comment: Acabei de colocá-la.
Comment: Foi, mas de forma estranha:
"[dia] => 2016-02-16T17:44:18.851Z"
Comment: Esse é o padrão, você terá que formatar a data de uma forma pra enviar pro BD ou então envia-la como Varchar
Answer: Assim tbm funcionaria:
<code>$scope.enviarMsg = function (mensagem) {
    var enviaMsg = {
        mensagem: mensagem,
        idUsuario: $window.localStorage.getItem('idUsuario'),
        idCep: $window.localStorage.getItem('idCep'),
        nome: $window.localStorage.getItem('nome'),
        date: new Date()
    }

    $http.post("http://www.vigilantescomunitarios.com/www/php/enviaMsgLogra.php", enviaMsg).success(function (data){

        console.log(data);
        pegaMsgsLogra();
        $scope.mensagem = {
          msg: ""
        }

    });
}
</code>


Add action links in custom module page

Question: I am writing a custom module for my project which handles a list of content (from custom db table) and content addition, following is my code.
function cp_menu() {
    $items = array();
    $items['admin/structure/package'] = array(
    'title' => t('Packages'),
        'page callback' => 'cp_packages_list',
        'access arguments' => array('administer access control'),
        'description' => t('Packages'),
        'type' => MENU_CALLBACK,
    );
    $items['admin/structure/package/add'] = array(
    'title' => t('Add package'),
        'page callback' => 'cp_form',
        'access arguments' => array('administer access control'),
        'description' => t('Add package'),
        'type' => MENU_CALLBACK,
    );
    return $items;
}

function cp_packages_list(){
    return 'this is a test page';
}
function cp_form() {
    return array('#markup'=>drupal_get_form('cp_my_form'));
}

it is working properly, but i want to show action links (add content type) at top of page like

How can i add action links on page?
my action links would be 'Add package' and 'View orders'
Answer: $items['admin/structure/types'] = array(
    'title' => 'Content types',
    'description' => 'Manage content types, including default status, front page promotion, comment settings, etc.',
    'page callback' => 'node_overview_types',
    'access arguments' => array('administer content types'),
    'file' => 'content_types.inc',
  );
  $items['admin/structure/types/list'] = array(
    'title' => 'List',
    'type' => MENU_DEFAULT_LOCAL_TASK,
    'weight' => -10,
  );
  $items['admin/structure/types/add'] = array(
    'title' => 'Add content type',
    'page callback' => 'drupal_get_form',
    'page arguments' => array('node_type_form'),
    'access arguments' => array('administer content types'),
    'type' => MENU_LOCAL_ACTION,
    'file' => 'content_types.inc',
  );

This is what exist on node.module, modify to set the type to MENU_LOCAL_ACTION
Hope that help.
Comment: It helps me to understand the menu structure but i am still not able to add action links.
Answer: You can use hook_menu_local_tasks_alter() to add action links on any page.
Output that $root_path to see what it is on a page, it is not the same as the actual path necessarily.
function YOURMODULE_menu_local_tasks_alter(&$data, $router_item, $root_path) {
  switch($root_path){
    case 'admin/structure/%':
      if ($router_item['original_map'][2] == 'path_arg') {
        $item = menu_get_item('admin/structure/types/add');
        if ($item['access']) {
          $data['actions']['output'][] = array(
            '#theme' => 'menu_local_action',
            '#link' => $item,
          );
        }
      }
    break;
  }
}

Credit to answer on d.o
Answer: Just change the type for the admin/structure/package/add from MENU_CALLBACK to MENU_LOCAL_ACTION. The purpose of MENU_LOCAL_ACTION is described in hook_menu().

MENU_LOCAL_ACTION: Local actions are menu items that describe actions on the parent item such as adding a new user or block, and are rendered in the action-links list in your theme.

In your case, the parent item of admin/structure/package/add is admin/structure/package, which is where you want the local action to appear.
Furthermore, there isn't any need to use a function that calls a form build as page callback: Just set 'drupal_get_form' as page callback and set array('cp_my_form') as page arguments.
The code to use for hook_menu() is the following one.
function cp_menu() {
  $items = array();

  $items['admin/structure/package'] = array(
    'title' => 'Packages',
    'description' => 'Packages',
    'page callback' => 'cp_packages_list',
    'access arguments' => array('administer access control'),
    'type' => MENU_CALLBACK,
  );

  $items['admin/structure/package/add'] = array(
    'title' => 'Add package',
    'description' => 'Add package',
    'page callback' => 'drupal_get_form',
    'page arguments' => array('cp_my_form')
    'access arguments' => array('administer access control'),
    'type' => MENU_LOCAL_ACTION,
  );

  return $items;
}

Also, the values for the menu title and the menu description are untranslated string. The description for those values given in the documentation for hook_menu() is clear about that.

"title": Required. The untranslated title of the menu item.
"description": The untranslated description of the menu item.

Add action links in custom module page


Upgrade from Debian Lenny to Squeeze with apt-get

Question: I just upgraded my system from Lenny to Squeeze following the steps posted here. I followed all the steps using apt-get (in the upgrade from Etch to Lenny i used aptitude as suggested) and the upgrade went fine.
In the daily routine I use aptitude to maintain the system up to date and I really like the automatic handling of unused packages, so if I install package A that depends on B when I remove A, B is removed too keeping my system clean.
My question is the following: do apt-get and aptitude share the automatic handling of packages? I don't think so, because I found a lot of packages not marked as Auto in aptitude after the upgrade via apt-get.
Am I right? How can I fix this in automated way if the answer is yes?
Comment: [I found the answer I need](http://www.debian.org/doc/manuals/reference/ch02.en.html#_the_package_state_for_apt)
Comment: This would be a good time to mutter about dselect and get of my lawn you kids.
Answer: (Adding an answer so the information is here, too)
aptitude keeps some state over and above the underlying apt-get system. This results in information set in one that the other doesn't know about. Years ago when I still used aptitude, I found myself doing update checks in both because I was getting confusing results. Using aptitude exclusively would hide this problem, but as soon as you something else, it becomes apparatnt.
Solution: either use only aptitude or never use aptitude.
Comment: ever since apt 0.7, apt and aptitude share the information about automatically installed pacakges.  Its no longer necessary to only use one or the other.
Comment: I always use aptitude, but this time I used apt-get because is recommended in the releases notes of Squeeze. Hope this won't give me problems in dependencies tracking in future updates.
Comment: @Stew, that's good to know. If only more people could be told about it, as otherwise aptitude may die a slow death.
Answer: The release notes say you should use apt-get to upgrade, not aptitude.
http://www.debian.org/releases/squeeze/i386/release-notes/ch-upgrading.en.html#upgradingpackages+

The recommended way to upgrade from previous Debian GNU/Linux
  releases is to use the package
  management tool apt-get. In previous
  releases, aptitude was recommended for
  this purpose, but recent versions of
  apt-get provide equivalent
  functionality and also have shown to
  more consistently give the desired
  upgrade results.
Comment: I did used apt-get for the upgrade, but usually I use aptitude for normal activities on the system. I want to know if this mix of usage could lead to strange behaviors in the future.
Comment: Fabio: no, this mix is fine.  In the past (before apt 0.7), the mix could cause problems, but this should no longer be the case.  If it were, the release team would certainly not be recommending it in the upgrade procedure.
Answer: You can have automatic handling of unused packages by using apt-get --auto-remove remove/purge.
If that's tedious to type, just make an alias. Mine is rr and rrp, respectively.


A finite cancellative monoid is a group? Need help seeing why the following is a false proof.

Question: I proved this in the following way is our exam, but got $0$ out of $7$ points for it, however I fail to see why its wrong:

Let $a\in S$ be arbitrary. Since $S$ is finite, there has to be some $m \in \mathbb{N}$ such that $a^m=e$, otherwise all the powers of $a$ would be different. Then $a^m = a^m(a^{-1}a)$, and by cancellation we get $e = a^{-1}a$, so that $a^{-1}$ is the left inverse.

Similarly I showed a right inverse exists, hence a unique two sided inverse exists, so $S$ is a group. Being periodic, I know some power of $a$ has to be an idempotent, so that power becomes the identity.
Comment: It looks more or less right. Finiteness gives that $a^m=a^{m+n}$ for some $m,n$. But $a^{m+n}=a^ma^n$, so we can cancel to get $a^n=1$. If $n=1$ we have $a=1$. For $n>1$ we have $a^{n-1}a=a^n=aa^{n-1}$, so $a^{n-1}$ is a two-sided inverse for $a$. If $b$ is another inverse, then we have $ab=aa^{n-1}$, so cancellation gives us $b=a^{n-1}$.
Comment: I find $0/7$ a little harsh! As James Mitchell says, the main problem is that you wrote $a^{-1}$ while trying to prove that $a^{-1}$ exists, which was probably regarded as a fatal mistake. But I would give it about $2/7$.
Answer: I suppose that $e$ is the identity of your monoid. Why does there have to be a power of $a$ equal to the identity? As the commenter above says there have to be two powers of $a$ that are equal but not necessarily equal to the identity, at least without first proving you the monoid is a group. Also when you write $a^m = a^m aa ^{-1}$ what is $a ^ {-1}$? You'd maybe like to say the inverse of $a$, but we don't know that there is one yet. You seem to be using the fact that your monoid is a group to prove that it is a group. You see the problem with that, right?
Comment: @conner. There is a critical difference. $a^{m-1}$ means $a\cdot a\cdot a\dots\cdot a$ (with $m-1$ $a$s). Whereas $a^{-1}$ means the inverse of $a$ whose existence you are trying to establish.
Comment: I see your points. Can this method be made to reach the right conclusion in another way still?
Comment: @almagest already wrote a correct solution in his comment, it is somewhat similar to your solution.
Comment: It seems more like I might not have used the 'correct' notation, otherwise, what is the difference between writing $a^{m-1} a$ and $a^{m} a^{-1} a$?
Comment: @almagest is correct, that's precisely the issue
Comment: @almagest You're right, and of course I know that. I'm just kicking myself about getting this proof wrong, hence the comment above, trying to convince you to say with me that I deserved some partial credit.


Can I use taskkill to kill a process running under a certain user?

Question: I need to kill foo.exe, but only under a certain user account.  Is this possible with taskkill?  In this case, killing all instances of foo.exe would be problematic.
Answer: taskkill /F /T /IM foo.exe /FI "USERNAME eq target_user"

should do it. /IM specifies the image name, and the /FI option specifies a filter to use, in this case, a user with the username "target_user".
In any case, you'll need to be an Administrator on the local system to forcefully terminate processes in another users security context
Comment: If you do not want to hard-code username, use `%USERNAME%` or `%USERDOMAIN%\%USERNAME%` for current user.
Comment: Sadly, it doesn't look like there's a filter to target a specific instance of a process based on its arguments (eg `taskkill /f /im notepad /fi "args contains 'd:\foo.txt'"`)


How do I restart the ioloop in tornado when fetching twitter stream api?

Question: I'm using TweetStream (https://github.com/joshmarshall/TweetStream), a tornado based twitter streaming module to monitor the stream api.
I would like to know how can I restart the fetch process if want to change the tracked words.
My current solution (not exactly a solution) is giving me some errors.
stream = tweetstream.TweetStream(configuration,ioloop=main_io_loop)

stream.fetch("/1.1/statuses/filter.json?track="+tornado.escape.url_escape(words), callback=callback)

def check_words():
    global words
    with open('words.txt') as file:
        newwords = file.read()
        if words != newwords:
            words = newwords
        try:
            print newwords
            stream.fetch("/1.1/statuses/filter.json?track="+tornado.escape.url_escape(words), callback=callback)
        except:
            pass
        file.close()

interval_ms = 1000*10
scheduler = tornado.ioloop.PeriodicCallback(check_words,interval_ms,io_loop = main_io_loop)
scheduler.start()
main_io_loop.start()

Here is the error i'm getting
ERROR:root:Uncaught exception, closing connection.
Traceback (most recent call last):
  File "/home/user/PycharmProjects/observrenv/local/lib/python2.7/site-packages/tornado/iostream.py", line 305, in wrapper
    callback(*args)
  File "/home/user/PycharmProjects/observrenv/src/tweetstream/tweetstream.py", line 155, in on_connect
    self._twitter_stream.read_until("\r\n\r\n", self.on_headers)
  File "/home/user/PycharmProjects/observrenv/local/lib/python2.7/site-packages/tornado/iostream.py", line 151, in read_until
    self._set_read_callback(callback)
  File "/home/user/PycharmProjects/observrenv/local/lib/python2.7/site-packages/tornado/iostream.py", line 369, in _set_read_callback
    assert not self._read_callback, "Already reading"
AssertionError: Already reading
ERROR:root:Exception in callback <tornado.stack_context._StackContextWrapper object at 0x2415cb0>
Traceback (most recent call last):
  File "/home/user/PycharmProjects/observrenv/local/lib/python2.7/site-packages/tornado/ioloop.py", line 421, in _run_callback
    callback()
  File "/home/user/PycharmProjects/observrenv/local/lib/python2.7/site-packages/tornado/iostream.py", line 305, in wrapper
    callback(*args)
  File "/home/user/PycharmProjects/observrenv/src/tweetstream/tweetstream.py", line 155, in on_connect
    self._twitter_stream.read_until("\r\n\r\n", self.on_headers)
  File "/home/user/PycharmProjects/observrenv/local/lib/python2.7/site-packages/tornado/iostream.py", line 151, in read_until
    self._set_read_callback(callback)
  File "/home/user/PycharmProjects/observrenv/local/lib/python2.7/site-packages/tornado/iostream.py", line 369, in _set_read_callback
    assert not self._read_callback, "Already reading"
AssertionError: Already reading

I achieved better results (no the best) by starting the ioloop again when calling check_words.
stream = tweetstream.TweetStream(configuration,ioloop=main_io_loop)

stream.fetch("/1.1/statuses/filter.json?track="+tornado.escape.url_escape(words), callback=callback)

def check_words():
    global words, stream
    with open('words.txt') as file:
        newwords = file.read()
    if words != newwords:
        words = newwords
        print newwords
        try:
            stream = tweetstream.TweetStream(configuration,ioloop=main_io_loop)
            stream.fetch("/1.1/statuses/filter.json?track="+tornado.escape.url_escape(words), callback=callback)
            interval_ms = 1000*10
            scheduler = tornado.ioloop.PeriodicCallback(check_words,interval_ms,io_loop = main_io_loop)
            scheduler.start()
            main_io_loop.start()
        except:
            pass
        file.close()

interval_ms = 1000*10
scheduler = tornado.ioloop.PeriodicCallback(check_words,interval_ms,io_loop = main_io_loop)
scheduler.start()
main_io_loop.start()

Answer: As it was said here by a twitter employee, the recommended is to do what I am already doing (but in a more moderated way). Just reconnect once a while if your query terms changed. Otherwise just keep the connection open. It's also important to monitor errors that twitter might send it to you or you might be banned.
Answer: Looks, like you are missing main idea of Streaming API.
Connection to it opened permanently.
stream = tweetstream.TweetStream(configuration,ioloop=main_io_loop)

#What you are doing in callback?
stream.fetch("/1.1/statuses/filter.json?track="+tornado.escape.url_escape(words), callback=callback)

def check_words():
    #I guess, don't do it at all.
    #global words
    #with open('words.txt') as file:
    #    newwords = file.read()
    #    if words != newwords:
    #        words = newwords
    #    try:
    #        #Don't open new stream here
    #        print newwords
    #    except:
    #        pass
    #    file.close()
    pass

interval_ms = 1000*10
scheduler = tornado.ioloop.PeriodicCallback(check_words,interval_ms,io_loop = main_io_loop)
scheduler.start()
main_io_loop.start()

By analizing your code, I think you just must do routine with new words in callback.
Comment: but if my needs changed (I need to monitor other words) how do I change that? If i'm monitoring "love" and then a user wants to monitor "hate", i believe I should change that fetch to "love,hate". I was thinking about stoping the io_loop and then start it over.
Comment: @gawry, best solution - stream "love,hate" and decide in your callback what word you have in stream. Pattern what you implemented above - will cause ban, because stream will aggressively reconnect. If for some reasons you have to monitor 2 words at one time, with one word per stream - use 2 threads. Yes, if you have changed words - restart thread.
Comment: So I believe I can just set the periodic call to a less frequent period to avoid being banned.


Getting a Clean Sound with a Vox VT20

Question: I've bought a Vox VT20 and while it's great, I'm having a hard time trying to get the cleanest sound possible. So far, I've found that the only way to do this is by turning on the tuner, but having the tuner on is really annoying while you are playing. What's the right setup to turn all effects off?
I've tried going to manual mode and the selecting the clean amp, setting value and depth to off, but I still notice some echo or reverb is added.
I checked the users manual, but I can't find the setup needed in order to get a clean sound.
Comment: Is it fair to assume that you have tried turning off all the effects including the reverb? I.E. the value knob is turned to the off position, the depth knob is turned to the off position, and the reverb knob is turned to the off position. Just so we're not giving answers to something you may have already tried. I am assuming your working with this interface: http://g-ecx.images-amazon.com/images/G/01/musical-instruments/detail-page/sc_b004jlx7b0-06top_lg.jpg
Answer: After trying the clean amp model, try lowering the Volume and Gain knobs a lot (as in less than a quarter turn even), and then just increasing the Master Volume. You may have to increase the Master Volume knob a lot since those other knobs are very low.
Always start from a low volume increasing slowly while giving your guitar a few strums to make sure that the amp doesn't turn out to be exceedingly loud after fiddling with the settings.
It's also possible that your guitar has a very high output, so it may help to lower the volume knob on your instrument as well to maybe half or less.

Getting a Clean Sound with a Vox VT20


how to fix background image and display nav bar horizontally outside of dreamweaver?

Question: I want to have the nav bar and logo overlayed on the same banner image.
However, I can't display my banner image. Also, when I preview my page in chrome or explorer rather then the design view of Dreamweaver, my Nav Bar is vertical rather then horizontal.
Jsfiddle
Here's my HTML:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" href="css/style.css" type="text/css">
<title>Banner and Navigation menu</title>

And my css:
@charset "utf-8";
@charset "utf-8";
/* CSS Document */
body {
    margin: 0px;
    padding: 0px;
}

#banner-container {
    width: 100%;
    height: 204px;
    background-color: #0071b2;
}

#banner {
    background-image: url('../css/homepage-banner.jpg');
    background-repeat: no-repeat;
    background-position: 100% 0;
    width: 1024px;
    height: 204px;
    margin: auto;
}

#logo-and-nav {
    width: 60%;
    height:200px;
    margin: 0 auto;
    text-align: center;

}

img {
    border: none;
}

#logo-and-nav ul
{
    text-align: left;
    margin: auto;
    width: 1024px;
}

#logo-and-nav ul li
{
    display: inline;
    padding: 0px;
    margin: 0px;
}

#new-products-and-sales
{
width: 500px;
    height: 100px;
    margin: auto;
}
#most-popular-products
{
    width: 500px;
    height: 100px;
    margin: auto;
}
#mugs
{
    width: 500px;
    height: 100px;
    margin: auto;
}
#hats
{
    width: 500px;
    height: 100px;
    margin: auto;
}
#shirts
{
    width: 500px;
    height: 100px;
    margin: auto;
}
#accessories
{
    width: 500px;
    height: 100px;
    margin: auto;
}
/* CSS Document */

Comment: Just a tip, never trust dreamweaver's design window. Always test in a proper browser.
Comment: Cheers. Now how would I do that?
Comment: to handle the display of the image you can use '../' in the image path or remove it. I got the same case as yours.
Answer: To achieve what you want is to set ul li in float, as follows:
ul li{
   float:left;
   padding:10px 0px 10px 0px;
   list-style:none;
}

You also can use display:inline or inline-block for that case, as follows:
ul li{
   display:inline;
   padding:10px 0px 10px 0px;
   list-style:none;
}

To get logo overlay on the same banner image, you the need place the URL of the image/logo/banner inside

DEMO in JSFiddle


vba@excel_highlight the empty cells

Question: I'm creating an excel file with column A to H are mandatory cells.
This excel file will be passing around for input.
So, I would like to highlight the empty cells as a reminder.
I have written the following code...
Sub Highlight_Cell()
Dim Rng As Range

For Each Rng In Range("A2:H20")
If Rng.Value = "" Then
Rng.Interior.ColorIndex = 6 'yellow
Else
Rng.Interior.ColorIndex = 0 'blank
End If
Next Rng
   MsgBox "Please fill in all mandatory fields highlighted in yellow."
End Sub

However, I would like to set the range from A2 to the last row that contains data within column A to H.
Also, display the message box only when empty cell exist.
Could you please advise how should I amend?
Million Thanks!!!
Comment: if the data in colulmn A:H can be blank then how do you know which is the last rows that contains data within A:H? Is there another data section outside this range that sets the limit?
Answer: This is a VBA solution that prevents the user from saving until the desired range is filled (acknowledging Gserg's comment that that the last row is one that has at least one cell entered)
In the second portion you can either add your sheet index directly, Set ws = Sheets(x) for position x, or Set ws = Sheets("YourSheet") for a specific sheet name
The code will only highlight truly blank cells within A to H of this sheet till the last entered cell (using SpecialCells as a shortcut). Any such cells will be selected by the code on exit

Put this code in the ThisWorkbook module (so it fires whenever the user tries to close the file)
Private Sub Workbook_BeforeClose(Cancel As Boolean)
bCheck = False
Call CheckCode
If bCheck Then Cancel = True
End Sub

Put this code in a standard module
Public bCheck As Boolean
Sub CheckCode()
Dim ws As Worksheet
Dim rng1 As Range
Dim rng2 As Range
bCheck = False
'works on sheet 1, change as needed
Set ws = Sheets(1)
Set rng1 = ws.Columns("A:H").Find("*", ws.[a1], xlValues, xlWhole, xlByRows)
If rng1 Is Nothing Then
    MsgBox "No Cells in columns A:H on " & ws.Name & " file will now close", vbCritical
    Exit Sub
End If
Set rng2 = ws.Range(ws.[a1], ws.Cells(rng1.Row, "H"))
On Error Resume Next
Set rng2 = rng2.SpecialCells(xlBlanks)
On Error GoTo 0
If rng2 Is Nothing Then Exit Sub
bCheck = True
rng2.Interior.Color = vbYellow
MsgBox "Please fill in all mandatory fields on " & ws.Name & " highlighted in yellow", vbCritical, "Save Cancelled!"
Application.Goto rng2.Cells(1)
End Sub

vba@excel_highlight the empty cells


Limit at infinity $\lim_{x\to \infty} x^a a^x=$?

Question: $\displaystyle \lim_{x\to \infty} x^a a^x=?$; $0<a<1$
I try to use the property: $a^{\log_a x}= x$ and reescribe the expression
$\displaystyle \lim_{x\to \infty} x^a a^x  =  \lim_{x\to \infty} \frac{a^{a\log_a x}}{a^{-x}} $ but i can't find the limit yet.
Any suggestion?
Answer: HINT
For $a\ge 1$ it is trivial.
For $0<a<1$ let $b=\frac1a>1$ then
$$x^aa^x=\frac{x^a}{b^x}$$
then we can easily conclude for example by l'Hopital.
Answer: Take the logarithm:
$\ln x^a a^x = a \ln x \, x \ln a = (a \ln a) (x \ln x)$
Here, $x \ln x \to \infty,$ but the factor $a \ln a$ can change the limit.
If $a>1$ then $a \ln a > 0$ so $(a \ln a) (x \ln x) \to \infty$ making $x^a a^x \to \infty.$
If $a=1$ then $a \ln a = 0$ so $(a \ln a) (x \ln x) \to 0$ making $x^a a^x \to 1.$
If $0<a<1$ then $a \ln a < 0$ so $(a \ln a) (x \ln x) \to -\infty$ making $x^a a^x \to 0.$
Answer: Consider $x=ay$; then your expression becomes
$$
x^aa^x=(ay)^aa^{ay}=a^a(ya^y)^a
$$
so you just need to compute
$$
\lim_{y\to\infty}ya^y
$$
For $a\ge1$ the limit is $\infty$. For $0<a<1$ rewrite it as
$$
\lim_{y\to\infty}\frac{y}{a^{-y}}=\lim_{y\to\infty}\frac{1}{-a^{-y}\log a}=0
$$
with a simple application of l'Hôpital.


No Android é possível inflar um layout dentro de uma gridview

Question: Estou tentando criar um leitor de e-book, na Activity principal deve aparecer um gridview onde cada posição deve apresentar uma miniatura da capa do livro, embaixo apareça o nome do livro, nome do autor e data de publicação: oque eu espero é algo desse tipo:

obs.:Favor desconsiderar as estrelas e o botão de opções só preciso da imagem e os três textos.
no momento estou utilizando um Gridview, para coloar dentro de cada posição um Linear layout que contém um imageview e três textview.
A minha pergunta é: Posso inflar um layout dentro de um gridview ou existe outra maneira de fazer o que estou pretendendo?
Answer: A melhor solução nesse caso é utilizar RecyclerView e GridLayoutManager.
O RecyclerView funciona como um ListView, ou seja, você precisará de um Adapter. Este Tutorial em português mostra como você pode utilizar o RecyclerView. Ele utiliza LinearLayoutManager. No seu caso, você irá utilizar o GridLayoutManager.


Ubuntu load average spikes but CPUs are idle

Question: We have a server on a cloud network, provided by a third party. We are running Ubuntu 10.04 Server Edition.
The problem happens at seemingly random times, around one to three times a day. The load average in top usually sits around 2 and the server runs peachy, but at these random times, the load average spikes to around 30-35 and everything grinds to a halt. Can't access our websites, can't execute commands on the server, can't do anything. Can't even log in if you weren't already logged in.
The only way we have been able to see the high load averages is by constantly running top so that it is already running when the problem occurs. Seems that if it's already running, it will keep working properly, but if it isn't running, you can't start it. The inability to run any commands when it gets into this state has been making it difficult for us to diagnose the problem...plus we do not consider ourselves server experts by any means.
The thing that looks weird to me is, the load average spikes so high, but the processors stay idle, and there is plenty of free memory. Again, I'm not an expert at all, but my very basic understanding was that if memory is availble and the processors aren't maxed out, then there shouldn't be processes waiting (very possible I'm mistaken on that).
As I was typing this, I caught it as it was starting to spike and managed to run a few commands before everything locked up. Output is as follows:
uname -a
Linux <server name> 2.6.32-308-ec2 #16-Ubuntu SMP Thu Sep 16 14:28:38 UTC 2010 i686 GNU/Linux

top
top - 10:55:08 up 15:28,  4 users,  load average: 12.29, 7.01, 3.89
Tasks: 313 total,   3 running, 308 sleeping,   0 stopped,   2 zombie
Cpu(s):  0.0%us,  0.0%sy,  0.0%ni,100.0%id,  0.0%wa,  0.0%hi,  0.0%si,  0.0%st
Mem:   4210704k total,  2163024k used,  2047680k free,   162320k buffers
Swap:  2096440k total,        0k used,  2096440k free,  1690464k cached

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
    1 root      20   0  2804 1644 1204 S    0  0.0   0:00.18 init
    2 root      20   0     0    0    0 S    0  0.0   0:00.00 kthreadd
    3 root      RT   0     0    0    0 R    0  0.0   0:00.08 migration/0
    4 root      20   0     0    0    0 S    0  0.0   0:00.01 ksoftirqd/0
    5 root      RT   0     0    0    0 R    0  0.0   0:00.01 watchdog/0
    6 root      20   0     0    0    0 S    0  0.0   0:00.06 events/0

ps axf
  PID TTY      STAT   TIME COMMAND
    2 ?        S      0:00 [kthreadd]
    3 ?        R      0:00  \_ [migration/0]
    4 ?        S      0:00  \_ [ksoftirqd/0]
    5 ?        R      0:00  \_ [watchdog/0]
    6 ?        S      0:00  \_ [events/0]
    7 ?        S      0:00  \_ [cpuset]
    8 ?        S      0:00  \_ [khelper]

<removed a bunch of processes to save space in the post, all had status S>

    1 ?        Ss     0:00 /sbin/init
  245 ?        S      0:00 upstart-udev-bridge --daemon
  251 ?        S /var/run/motd.new
25554 ?        S      0:00          \_ run-parts --lsbsysinit /etc/update-motd.d
25558 ?        S      0:00              \_ /bin/sh /etc/update-motd.d/10-help-text
25560 ?        D      0:00                  \_ /bin/sh /etc/update-motd.d/10-help-text
  852 ?        Ss     0:00 cron
 1374 ?        S      0:00  \_ CRON
 1377 ?        Ss     0:00  |   \_ /bin/sh -c /var/www/secure/caddy2_prod/scripts/main.pl
 1379 ?        S      0:02  |       \_ /usr/bin/perl /var/www/secure/caddy2_prod/scripts/main.pl
 1385 ?        Z      0:00  |           \_ [check.pl]
 1375 ?        S      0:00  \_ CRON
 1376 ?        Ss     0:00      \_ /bin/sh -c /var/www/secure/caddy2_test/scripts/main.pl
 1378 ?        S      0:00          \_ /usr/bin/perl /var/www/secure/caddy2_test/scripts/main.pl
 1384 ?        Z      0:00              \_ [check.pl]
  855 ?        Ss     0:00 atd
  868 ?        Ssl    6:36 /usr/sbin/mysqld
  890 ?        S      0:00 /bin/bash /usr/sbin/xe-daemon -p /var/run/xe-daemon.pid
25563 ?        S      0:00  \_ /bin/sh /usr/sbin/xe-update-guest-attrs --memory
25564 ?        D      0:00      \_ /bin/sh /usr/sbin/xe-update-guest-attrs --memory
 1161 ?        Ss     0:00 /usr/lib/postfix/master
 3102 ?        S      0:00  \_ qmgr -l -t fifo -u
22013 ?        S      0:00  \_ pickup -l -t fifo -u -c
 1181 ?        Ssl    3:17 /usr/sbin/asterisk -p -U asterisk
 1182 ?        S      0:00  \_ astcanary /var/run/asterisk/alt.asterisk.canary.tweet.tweet.tweet
 1222 ?        Ss     0:00 /usr/sbin/apache2 -k start
31682 ?        S      0:01  \_ /usr/sbin/apache2 -k start
31716 ?        S      0:01  \_ /usr/sbin/apache2 -k start
13548 ?        S      0:00  \_ /usr/sbin/apache2 -k start
25593 ?        S      0:00  |   \_ /usr/bin/perl -w /usr/lib/cgi-bin/caddy2/patch.pl
25594 ?        D      0:00  |       \_ /usr/bin/perl -w /usr/lib/cgi-bin/caddy2/patch.pl
13637 ?        S      0:00  \_ /usr/sbin/apache2 -k start
16061 ?        S      0:00  \_ /usr/sbin/apache2 -k start
23116 ?        S      0:00  \_ /usr/sbin/apache2 -k start
25565 ?        D      0:00  |   \_ /usr/sbin/apache2 -k start
23117 ?        S      0:00  \_ /usr/sbin/apache2 -k start
23118 ?        S      0:00  \_ /usr/sbin/apache2 -k start
23119 ?        S      0:00  \_ /usr/sbin/apache2 -k start
23121 ?        S      0:00  \_ /usr/sbin/apache2 -k start
 1268 tty1     Ss+    0:00 /sbin/getty -8 38400 tty1
 1396 ?        S      0:00 /usr/local/caddy2/servers/test/caddy2serverd localhost caddy2test 1981

<removed a bunch of processes like the one above to save space in the post, there were about 100, all with status S>

25590 ?        S      0:00  \_ /usr/local/caddy2/servers/prod/caddy2serverd localhost caddy2prod 1991
25538 ?        D      0:00 /bin/bash ./impsys-snap.sh nohup
25596 ?        Ss     0:00 /sbin/getty -L hvc0 9600 linux

I do notice that there are a few process in the D state, which I think indicates that it is a zombie process. I have no idea if those are the cause of the issue, or what the difference is between processes in D state vs. processes in Z state.
If we think that these are what's causing the problem, what can I do about it? I have no idea what causes a process to go into the D state, and therefore have no idea how to prevent it from happening.
Your help is greatly appreciated. Thanks!
UPDATE:
I looked at our kern.log and found that it is littered with messages like these:
<removed to clean up post, further detail added below>

The timestamp on some of these seems to coincide with the time that the server locks up on us, so I'm think that has something to do with it. We have passed this information to our server provider as well, but does this indicate anything useful? If so, does it indicate a problem on my end, or my server provider's end?
UPDATE 2:
Here is the kern.log for the entire time that seemed relevant. At 10:52:24, the load average started going up. I got the output of the ps axf at about 10:54:02. After a minute or two (possibly exactly two minutes, if 10:56:02 indicates it), the system became unresponsive and I could not execute commands. Here is the log:

Mar 25 08:08:57 cloud kernel: [45483.026983] INFO: task apache2:9642 blocked for more than 120 seconds.
Mar 25 08:08:57 cloud kernel: [45483.026986] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
Mar 25 08:08:57 cloud kernel: [45483.026989] apache2       D ea63de60     0  9642   9068 0x00000000
Mar 25 08:08:57 cloud kernel: [45483.026992]  ea63de78 00000282 ea63ded4 ea63de60 c01d9096 00000000 00000000 00000000
Mar 25 08:08:57 cloud kernel: [45483.026996]  c06f61c0 ea1a6fac c06f61c0 c06f61c0 c06f61c0 ea1a6fac c06f61c0 c06f61c0
Mar 25 08:08:57 cloud kernel: [45483.027000]  c1305740 0000296f ea1a6d00 ec844d00 9a352c09 0003c456 ea63dea0 c0106c51
Mar 25 08:08:57 cloud kernel: [45483.027003] Call Trace:
Mar 25 08:08:57 cloud kernel: [45483.027006]  [] ? __link_path_walk+0x626/0xc20
Mar 25 08:08:57 cloud kernel: [45483.027010]  [] ? sched_clock+0x21/0x80
Mar 25 08:08:57 cloud kernel: [45483.027013]  [] schedule_timeout+0x175/0x250
Mar 25 08:08:57 cloud kernel: [45483.027018]  [] ? sched_clock_cpu+0x14d/0x190
Mar 25 08:08:57 cloud kernel: [45483.027021]  [] ? find_idlest_group+0xa8/0x1b0
Mar 25 08:08:57 cloud kernel: [45483.027023]  [] wait_for_common+0xc6/0x180
Mar 25 08:08:57 cloud kernel: [45483.027026]  [] ? default_wake_function+0x0/0x10
Mar 25 08:08:57 cloud kernel: [45483.027028]  [] wait_for_completion+0x12/0x20
Mar 25 08:08:57 cloud kernel: [45483.027031]  [] sched_migrate_task+0xe4/0x100
Mar 25 08:08:57 cloud kernel: [45483.027033]  [] sched_exec+0x3b/0x50
Mar 25 08:08:57 cloud kernel: [45483.027036]  [] do_execve+0xc4/0x360
Mar 25 08:08:57 cloud kernel: [45483.027038]  [] sys_execve+0x28/0x60
Mar 25 08:08:57 cloud kernel: [45483.027041]  [] syscall_call+0x7/0xb
Mar 25 09:27:03 cloud kernel: [50344.466167] nf_conntrack version 0.5.0 (16384 buckets, 65536 max)
Mar 25 09:27:03 cloud kernel: [50344.466452] CONFIG_NF_CT_ACCT is deprecated and will be removed soon. Please use
Mar 25 09:27:03 cloud kernel: [50344.466454] nf_conntrack.acct=1 kernel parameter, acct=1 nf_conntrack module option or
Mar 25 09:27:03 cloud kernel: [50344.466455] sysctl net.netfilter.nf_conntrack_acct=1 to enable it.
Mar 25 10:52:24 cloud kernel: [55167.785176] BUG: soft lockup - CPU#0 stuck for 61s! [swapper:0]
Mar 25 10:52:24 cloud kernel: [55167.785202] Modules linked in: nf_conntrack_ipv4 nf_conntrack nf_defrag_ipv4 ib_iser rdma_cm ib_cm iw_cm ib_sa ib_mad ib_core ib_addr iscsi_tcp libiscsi_tcp libiscsi scsi_transport_iscsi ipv6 scsi_mod lp parport
Mar 25 10:52:24 cloud kernel: [55167.785217]
Mar 25 10:52:24 cloud kernel: [55167.785221] Pid: 0, comm: swapper Not tainted (2.6.32-308-ec2 #16-Ubuntu)
Mar 25 10:52:24 cloud kernel: [55167.785224] EIP: 0061:[] EFLAGS: 00000246 CPU: 0
Mar 25 10:52:24 cloud kernel: [55167.785228] EIP is at 0xc01013a7
Mar 25 10:52:24 cloud kernel: [55167.785230] EAX: 00000000 EBX: 00000001 ECX: 00000000 EDX: c0689f58
Mar 25 10:52:24 cloud kernel: [55167.785232] ESI: c06beb08 EDI: a8b0d3bc EBP: c0689f78 ESP: c0689f70
Mar 25 10:52:24 cloud kernel: [55167.785235]  DS: 007b ES: 007b FS: 00d8 GS: 00e0 SS: 0069
Mar 25 10:52:24 cloud kernel: [55167.785242] CR0: 8005003b CR2: b6620000 CR3: 2a65e000 CR4: 00002660
Mar 25 10:52:24 cloud kernel: [55167.785247] DR0: 00000000 DR1: 00000000 DR2: 00000000 DR3: 00000000
Mar 25 10:52:24 cloud kernel: [55167.785250] DR6: ffff0ff0 DR7: 00000400
Mar 25 10:52:24 cloud kernel: [55167.785252] Call Trace:
Mar 25 10:52:24 cloud kernel: [55167.785259]  [] ? xen_safe_halt+0x15/0x40
Mar 25 10:52:24 cloud kernel: [55167.785264]  [] xen_idle+0x29/0x80
Mar 25 10:52:24 cloud kernel: [55167.785267]  [] cpu_idle+0x8f/0xc0
Mar 25 10:52:24 cloud kernel: [55167.785272]  [] rest_init+0x53/0x60
Mar 25 10:52:24 cloud kernel: [55167.785278]  [] start_kernel+0x379/0x37f
Mar 25 10:52:24 cloud kernel: [55167.785282]  [] ? unknown_bootoption+0x0/0x1a0
Mar 25 10:52:24 cloud kernel: [55167.785286]  [] i386_start_kernel+0x67/0x6e
Mar 25 10:53:30 cloud kernel: [55233.281412] BUG: soft lockup - CPU#0 stuck for 61s! [swapper:0]
Mar 25 10:53:30 cloud kernel: [55233.281421] Modules linked in: nf_conntrack_ipv4 nf_conntrack nf_defrag_ipv4 ib_iser rdma_cm ib_cm iw_cm ib_sa ib_mad ib_core ib_addr iscsi_tcp libiscsi_tcp libiscsi scsi_transport_iscsi ipv6 scsi_mod lp parport
Mar 25 10:53:30 cloud kernel: [55233.281444]
Mar 25 10:53:30 cloud kernel: [55233.281449] Pid: 0, comm: swapper Not tainted (2.6.32-308-ec2 #16-Ubuntu)
Mar 25 10:53:30 cloud kernel: [55233.281453] EIP: 0061:[] EFLAGS: 00000246 CPU: 0
Mar 25 10:53:30 cloud kernel: [55233.281457] EIP is at 0xc01013a7
Mar 25 10:53:30 cloud kernel: [55233.281460] EAX: 00000000 EBX: 00000001 ECX: 00000000 EDX: c0689f58
Mar 25 10:53:30 cloud kernel: [55233.281463] ESI: c06beb08 EDI: a8b0d3bc EBP: c0689f78 ESP: c0689f70
Mar 25 10:53:30 cloud kernel: [55233.281466]  DS: 007b ES: 007b FS: 00d8 GS: 00e0 SS: 0069
Mar 25 10:53:30 cloud kernel: [55233.281474] CR0: 8005003b CR2: 09827024 CR3: 013c4000 CR4: 00002660
Mar 25 10:53:30 cloud kernel: [55233.281480] DR0: 00000000 DR1: 00000000 DR2: 00000000 DR3: 00000000
Mar 25 10:53:30 cloud kernel: [55233.281484] DR6: ffff0ff0 DR7: 00000400
Mar 25 10:53:30 cloud kernel: [55233.281487] Call Trace:
Mar 25 10:53:30 cloud kernel: [55233.281498]  [] ? xen_safe_halt+0x15/0x40
Mar 25 10:53:30 cloud kernel: [55233.281504]  [] xen_idle+0x29/0x80
Mar 25 10:53:30 cloud kernel: [55233.281509]  [] cpu_idle+0x8f/0xc0
Mar 25 10:53:30 cloud kernel: [55233.281516]  [] rest_init+0x53/0x60
Mar 25 10:53:30 cloud kernel: [55233.281524]  [] start_kernel+0x379/0x37f
Mar 25 10:53:30 cloud kernel: [55233.281529]  [] ? unknown_bootoption+0x0/0x1a0
Mar 25 10:53:30 cloud kernel: [55233.281535]  [] i386_start_kernel+0x67/0x6e
Mar 25 10:54:36 cloud kernel: [55298.785478] BUG: soft lockup - CPU#0 stuck for 61s! [swapper:0]
Mar 25 10:54:36 cloud kernel: [55298.785538] Modules linked in: nf_conntrack_ipv4 nf_conntrack nf_defrag_ipv4 ib_iser rdma_cm ib_cm iw_cm ib_sa ib_mad ib_core ib_addr iscsi_tcp libiscsi_tcp libiscsi scsi_transport_iscsi ipv6 scsi_mod lp parport
Mar 25 10:54:36 cloud kernel: [55298.785551]
Mar 25 10:54:36 cloud kernel: [55298.785554] Pid: 0, comm: swapper Not tainted (2.6.32-308-ec2 #16-Ubuntu)
Mar 25 10:54:36 cloud kernel: [55298.785556] EIP: 0061:[] EFLAGS: 00000246 CPU: 0
Mar 25 10:54:36 cloud kernel: [55298.785560] EIP is at 0xc01013a7
Mar 25 10:54:36 cloud kernel: [55298.785561] EAX: 00000000 EBX: 00000001 ECX: 00000000 EDX: c0689f58
Mar 25 10:54:36 cloud kernel: [55298.785563] ESI: c06beb08 EDI: a8b0d3bc EBP: c0689f78 ESP: c0689f70
Mar 25 10:54:36 cloud kernel: [55298.785565]  DS: 007b ES: 007b FS: 00d8 GS: 00e0 SS: 0069
Mar 25 10:54:36 cloud kernel: [55298.785570] CR0: 8005003b CR2: 08ddb00c CR3: 28e7a000 CR4: 00002660
Mar 25 10:54:36 cloud kernel: [55298.785573] DR0: 00000000 DR1: 00000000 DR2: 00000000 DR3: 00000000
Mar 25 10:54:36 cloud kernel: [55298.785575] DR6: ffff0ff0 DR7: 00000400
Mar 25 10:54:36 cloud kernel: [55298.785576] Call Trace:
Mar 25 10:54:36 cloud kernel: [55298.785584]  [] ? xen_safe_halt+0x15/0x40
Mar 25 10:54:36 cloud kernel: [55298.785588]  [] xen_idle+0x29/0x80
Mar 25 10:54:36 cloud kernel: [55298.785591]  [] cpu_idle+0x8f/0xc0
Mar 25 10:54:36 cloud kernel: [55298.785596]  [] rest_init+0x53/0x60
Mar 25 10:54:36 cloud kernel: [55298.785602]  [] start_kernel+0x379/0x37f
Mar 25 10:54:36 cloud kernel: [55298.785605]  [] ? unknown_bootoption+0x0/0x1a0
Mar 25 10:54:36 cloud kernel: [55298.785608]  [] i386_start_kernel+0x67/0x6e
Mar 25 10:54:57 cloud kernel: [55318.911014] INFO: task impsys-snap.sh:25538 blocked for more than 120 seconds.
Mar 25 10:54:57 cloud kernel: [55318.911056] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
Mar 25 10:54:57 cloud kernel: [55318.911061] impsys-snap.s D e8ac5e60     0 25538      1 0x00000004
Mar 25 10:54:57 cloud kernel: [55318.911065]  e8ac5e78 00000282 ec53bb64 e8ac5e60 c01d9498 00000000 00000000 00000000
Mar 25 10:54:57 cloud kernel: [55318.911072]  c06f61c0 c13088dc c06f61c0 c06f61c0 c06f61c0 c13088dc c06f61c0 c06f61c0
Mar 25 10:54:57 cloud kernel: [55318.911077]  ea1d5040 00003221 c1308630 c068d280 c012abc8 0003cd53 0004ae99 e8ac5eac
Mar 25 10:54:57 cloud kernel: [55318.911083] Call Trace:
Mar 25 10:54:57 cloud kernel: [55318.911092]  [] ? __link_path_walk+0xa28/0xc20
Mar 25 10:54:57 cloud kernel: [55318.911098]  [] ? inc_rt_group+0xf8/0x110
Mar 25 10:54:57 cloud kernel: [55318.911103]  [] ? update_curr+0x169/0x2c0
Mar 25 10:54:57 cloud kernel: [55318.911114]  [] schedule_timeout+0x175/0x250
Mar 25 10:54:57 cloud kernel: [55318.911117]  [] ? check_preempt_wakeup+0x152/0x370
Mar 25 10:54:57 cloud kernel: [55318.911120]  [] wait_for_common+0xc6/0x180
Mar 25 10:54:57 cloud kernel: [55318.911122]  [] ? default_wake_function+0x0/0x10
Mar 25 10:54:57 cloud kernel: [55318.911125]  [] wait_for_completion+0x12/0x20
Mar 25 10:54:57 cloud kernel: [55318.911128]  [] sched_migrate_task+0xe4/0x100
Mar 25 10:54:57 cloud kernel: [55318.911130]  [] sched_exec+0x3b/0x50
Mar 25 10:54:57 cloud kernel: [55318.911134]  [] do_execve+0xc4/0x360
Mar 25 10:54:57 cloud kernel: [55318.911137]  [] sys_execve+0x28/0x60
Mar 25 10:54:57 cloud kernel: [55318.911139]  [] syscall_call+0x7/0xb
Mar 25 10:54:57 cloud kernel: [55318.911142] INFO: task lesspipe:25544 blocked for more than 120 seconds.
Mar 25 10:54:57 cloud kernel: [55318.911145] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
Mar 25 10:54:57 cloud kernel: [55318.911148] lesspipe      D e9487e60     0 25544  25543 0x00000000
Mar 25 10:54:57 cloud kernel: [55318.911151]  e9487e78 00000286 e9487ed4 e9487e60 c01d9096 c01e1204 00000000 00000000
Mar 25 10:54:57 cloud kernel: [55318.911155]  c06f61c0 ec3bb4ec c06f61c0 c06f61c0 c06f61c0 ec3bb4ec c06f61c0 c06f61c0
Mar 25 10:54:57 cloud kernel: [55318.911159]  ec269900 00003221 ec3bb240 c068d280 6d9860b9 0003cd53 e9487ea0 c0106c51
Mar 25 10:54:57 cloud kernel: [55318.911163] Call Trace:
Mar 25 10:54:57 cloud kernel: [55318.911165]  [] ? __link_path_walk+0x626/0xc20
Mar 25 10:54:57 cloud kernel: [55318.911169]  [] ? dput+0x84/0x160
Mar 25 10:54:57 cloud kernel: [55318.911172]  [] ? sched_clock+0x21/0x80
Mar 25 10:54:57 cloud kernel: [55318.911175]  [] schedule_timeout+0x175/0x250
Mar 25 10:54:57 cloud kernel: [55318.911179]  [] ? sched_clock_cpu+0x14d/0x190
Mar 25 10:54:57 cloud kernel: [55318.911181]  [] ? find_idlest_group+0xa8/0x1b0
Mar 25 10:54:57 cloud kernel: [55318.911184]  [] wait_for_common+0xc6/0x180
Mar 25 10:54:57 cloud kernel: [55318.911187]  [] ? default_wake_function+0x0/0x10
Mar 25 10:54:57 cloud kernel: [55318.911189]  [] wait_for_completion+0x12/0x20
Mar 25 10:54:57 cloud kernel: [55318.911192]  [] sched_migrate_task+0xe4/0x100
Mar 25 10:54:57 cloud kernel: [55318.911194]  [] sched_exec+0x3b/0x50
Mar 25 10:54:57 cloud kernel: [55318.911197]  [] do_execve+0xc4/0x360
Mar 25 10:54:57 cloud kernel: [55318.911199]  [] sys_execve+0x28/0x60
Mar 25 10:54:57 cloud kernel: [55318.911201]  [] syscall_call+0x7/0xb
Mar 25 10:54:57 cloud kernel: [55318.911204] INFO: task 10-help-text:25560 blocked for more than 120 seconds.
Mar 25 10:54:57 cloud kernel: [55318.911206] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
Mar 25 10:54:57 cloud kernel: [55318.911209] 10-help-text  D e8995e60     0 25560  25558 0x00000000
Mar 25 10:54:57 cloud kernel: [55318.911211]  e8995e78 00000282 e8995ed4 e8995e60 c01d9096 00000000 00000000 00000000
Mar 25 10:54:57 cloud kernel: [55318.911215]  c06f61c0 e8af122c c06f61c0 c06f61c0 c06f61c0 e8af122c c06f61c0 c06f61c0
Mar 25 10:54:57 cloud kernel: [55318.911219]  ec295e40 00003229 e8af0f80 c068d280 3d76c004 0003cd5c e8995ea0 c0106c51
Mar 25 10:54:57 cloud kernel: [55318.911223] Call Trace:
Mar 25 10:54:57 cloud kernel: [55318.911225]  [] ? __link_path_walk+0x626/0xc20
Mar 25 10:54:57 cloud kernel: [55318.911228]  [] ? sched_clock+0x21/0x80
Mar 25 10:54:57 cloud kernel: [55318.911231]  [] schedule_timeout+0x175/0x250
Mar 25 10:54:57 cloud kernel: [55318.911233]  [] ? sched_clock_cpu+0x14d/0x190
Mar 25 10:54:57 cloud kernel: [55318.911236]  [] ? find_idlest_group+0xa8/0x1b0
Mar 25 10:54:57 cloud kernel: [55318.911238]  [] wait_for_common+0xc6/0x180
Mar 25 10:54:57 cloud kernel: [55318.911241]  [] ? default_wake_function+0x0/0x10
Mar 25 10:54:57 cloud kernel: [55318.911243]  [] wait_for_completion+0x12/0x20
Mar 25 10:54:57 cloud kernel: [55318.911246]  [] sched_migrate_task+0xe4/0x100
Mar 25 10:54:57 cloud kernel: [55318.911248]  [] sched_exec+0x3b/0x50
Mar 25 10:54:57 cloud kernel: [55318.911251]  [] do_execve+0xc4/0x360
Mar 25 10:54:57 cloud kernel: [55318.911253]  [] sys_execve+0x28/0x60
Mar 25 10:54:57 cloud kernel: [55318.911256]  [] syscall_call+0x7/0xb
Mar 25 10:54:57 cloud kernel: [55318.911258] INFO: task xe-update-guest:25564 blocked for more than 120 seconds.
Mar 25 10:54:57 cloud kernel: [55318.911260] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
Mar 25 10:54:57 cloud kernel: [55318.911263] xe-update-gue D e9535e60     0 25564  25563 0x00000000
Mar 25 10:54:57 cloud kernel: [55318.911265]  e9535e78 00000286 e9535ed4 e9535e60 c01d9096 c01e1204 00000000 00000000
Mar 25 10:54:57 cloud kernel: [55318.911269]  c06f61c0 ea09685c c06f61c0 c06f61c0 c06f61c0 ea09685c c06f61c0 c06f61c0
Mar 25 10:54:57 cloud kernel: [55318.911273]  ec269ac0 0000322b ea0965b0 c068d280 f58f849c 0003cd5d e9535ea0 c0106c51
Mar 25 10:54:57 cloud kernel: [55318.911277] Call Trace:
Mar 25 10:54:57 cloud kernel: [55318.911279]  [] ? __link_path_walk+0x626/0xc20
Mar 25 10:54:57 cloud kernel: [55318.911282]  [] ? dput+0x84/0x160
Mar 25 10:54:57 cloud kernel: [55318.911284]  [] ? sched_clock+0x21/0x80
Mar 25 10:54:57 cloud kernel: [55318.911287]  [] schedule_timeout+0x175/0x250
Mar 25 10:54:57 cloud kernel: [55318.911290]  [] ? sched_clock_cpu+0x14d/0x190
Mar 25 10:54:57 cloud kernel: [55318.911292]  [] ? find_idlest_group+0xa8/0x1b0
Mar 25 10:54:57 cloud kernel: [55318.911294]  [] wait_for_common+0xc6/0x180
Mar 25 10:54:57 cloud kernel: [55318.911297]  [] ? default_wake_function+0x0/0x10
Mar 25 10:54:57 cloud kernel: [55318.911299]  [] wait_for_completion+0x12/0x20
Mar 25 10:54:57 cloud kernel: [55318.911302]  [] sched_migrate_task+0xe4/0x100
Mar 25 10:54:57 cloud kernel: [55318.911305]  [] sched_exec+0x3b/0x50
Mar 25 10:54:57 cloud kernel: [55318.911307]  [] do_execve+0xc4/0x360
Mar 25 10:54:57 cloud kernel: [55318.911310]  [] sys_execve+0x28/0x60
Mar 25 10:54:57 cloud kernel: [55318.911312]  [] syscall_call+0x7/0xb
Mar 25 10:54:57 cloud kernel: [55318.911314] INFO: task apache2:25565 blocked for more than 120 seconds.
Mar 25 10:54:57 cloud kernel: [55318.911316] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
Mar 25 10:54:57 cloud kernel: [55318.911319] apache2       D e899be60     0 25565  23116 0x00000000
Mar 25 10:54:57 cloud kernel: [55318.911321]  e899be78 00000282 e899bed4 e899be60 c01d9096 c068afa0 00000000 00000000
Mar 25 10:54:57 cloud kernel: [55318.911325]  c06f61c0 e949522c c06f61c0 c06f61c0 c06f61c0 e949522c c06f61c0 c06f61c0
Mar 25 10:54:57 cloud kernel: [55318.911329]  ec31f040 0000322c e9494f80 c068d280 1fcfd913 0003cd5f e899bea0 c0106c51
Mar 25 10:54:57 cloud kernel: [55318.911333] Call Trace:
Mar 25 10:54:57 cloud kernel: [55318.911336]  [] ? __link_path_walk+0x626/0xc20
Mar 25 10:54:57 cloud kernel: [55318.911338]  [] ? sched_clock+0x21/0x80
Mar 25 10:54:57 cloud kernel: [55318.911341]  [] schedule_timeout+0x175/0x250
Mar 25 10:54:57 cloud kernel: [55318.911343]  [] ? sched_clock_cpu+0x14d/0x190
Mar 25 10:54:57 cloud kernel: [55318.911346]  [] ? find_idlest_group+0xa8/0x1b0
Mar 25 10:54:57 cloud kernel: [55318.911348]  [] wait_for_common+0xc6/0x180
Mar 25 10:54:57 cloud kernel: [55318.911351]  [] ? default_wake_function+0x0/0x10
Mar 25 10:54:57 cloud kernel: [55318.911353]  [] wait_for_completion+0x12/0x20
Mar 25 10:54:57 cloud kernel: [55318.911356]  [] sched_migrate_task+0xe4/0x100
Mar 25 10:54:57 cloud kernel: [55318.911359]  [] sched_exec+0x3b/0x50
Mar 25 10:54:57 cloud kernel: [55318.911361]  [] do_execve+0xc4/0x360
Mar 25 10:54:57 cloud kernel: [55318.911364]  [] sys_execve+0x28/0x60
Mar 25 10:54:57 cloud kernel: [55318.911366]  [] syscall_call+0x7/0xb
Mar 25 10:56:02 cloud kernel: [55383.610034] BUG: soft lockup - CPU#0 stuck for 61s! [swapper:0]
Mar 25 10:56:02 cloud kernel: [55383.610056] Modules linked in: nf_conntrack_ipv4 nf_conntrack nf_defrag_ipv4 ib_iser rdma_cm ib_cm iw_cm ib_sa ib_mad ib_core ib_addr iscsi_tcp libiscsi_tcp libiscsi scsi_transport_iscsi ipv6 scsi_mod lp parport
Mar 25 10:56:02 cloud kernel: [55383.610073]
Mar 25 10:56:02 cloud kernel: [55383.610077] Pid: 0, comm: swapper Not tainted (2.6.32-308-ec2 #16-Ubuntu)
Mar 25 10:56:02 cloud kernel: [55383.610080] EIP: 0061:[] EFLAGS: 00000246 CPU: 0
Mar 25 10:56:02 cloud kernel: [55383.610084] EIP is at 0xc01013a7
Mar 25 10:56:02 cloud kernel: [55383.610086] EAX: 00000000 EBX: 00000001 ECX: 00000000 EDX: c0689f58
Mar 25 10:56:02 cloud kernel: [55383.610089] ESI: c06beb08 EDI: a8b0d3bc EBP: c0689f78 ESP: c0689f70
Mar 25 10:56:02 cloud kernel: [55383.610091]  DS: 007b ES: 007b FS: 00d8 GS: 00e0 SS: 0069
Mar 25 10:56:02 cloud kernel: [55383.610097] CR0: 8005003b CR2: 098c801c CR3: 2a6d2000 CR4: 00002660
Mar 25 10:56:02 cloud kernel: [55383.610104] DR0: 00000000 DR1: 00000000 DR2: 00000000 DR3: 00000000
Mar 25 10:56:02 cloud kernel: [55383.610106] DR6: ffff0ff0 DR7: 00000400
Mar 25 10:56:02 cloud kernel: [55383.610107] Call Trace:
Mar 25 10:56:02 cloud kernel: [55383.610115]  [] ? xen_safe_halt+0x15/0x40
Mar 25 10:56:02 cloud kernel: [55383.610119]  [] xen_idle+0x29/0x80
Mar 25 10:56:02 cloud kernel: [55383.610122]  [] cpu_idle+0x8f/0xc0
Mar 25 10:56:02 cloud kernel: [55383.610127]  [] rest_init+0x53/0x60
Mar 25 10:56:02 cloud kernel: [55383.610133]  [] start_kernel+0x379/0x37f
Mar 25 10:56:02 cloud kernel: [55383.610136]  [] ? unknown_bootoption+0x0/0x1a0
Mar 25 10:56:02 cloud kernel: [55383.610139]  [] i386_start_kernel+0x67/0x6e

Answer: D is uninterruptible wait, which once upon a time was Disk wait, but these days often has more to do with waiting for network filesystems.  These processes count in the load average, which may be your problem.
The thing that jumps out at me from the ps output is the second-last line:  a filesystem (NAS?) is being snapshotted, and probably all disk activity to that filesystem is being blocked during the snapshot.  Ways to deal with this include but aren't limited to using a cachefs over it and snapshotting more often so they go faster; which to use depends on the NAS (some of them suck during snapshots no matter what), available disk space, and your needs.  I would start by looking for s support community (not necessarily vendor support) for the NAS to see what tricks other users have come up with to minimize snapshot latency.
Comment: So how do I prevent them from going into that D state? When the load average spikes, everything stops responding. Sometimes it is able to recover on its own after a few minutes, sometimes we have to restart the server. Obviously this is not acceptable, so we need to figure out how to prevent these problems. Any suggestions?
Comment: See edited response for details.  You need to find a way to make the snapshot more lightweight.
Comment: Thanks for the suggestion. I don't think the snapshot process is the problem, that is something that our server provider gave us to run in order to help diagnose this problem, so it existed before we were running that. I did make a discovery (I think) in the kern.log file. See updated question.
Comment: That stands a very good chance of being related, yes.  The symptoms you're describing are consistent with a VFS deadlock, which is why I keyed onto the snapshot.    Your update confirms that... well, "deadlock" is the least of the problems. :)  And the stack trace strongly suggests that either you're hitting a Xen bug or Xen is tripping over something else failing (which would hopefully be in your provider's logs).
Comment: So do you think I should just wait and see what my provider says, or is there something I can do on my end to either fix this problem or narrow it down further? Thanks again for your help!
Comment: If there's any other possibly related log information around the CPU lockup, it might be interesting to see; NFS and/or iSCSI *might* be involved, there's no way to know with the information you've provided so far but either could lead to VFS deadlocks.  Also, consider syslog over the network to another machine (see `syslog.conf(5)`); it might make it easier to catch the problem without constant monitoring.
Comment: I added more of the kern.log file, and it should now show everything relevant to the latest crash. I'm not sure where else to look for relevant information, so if there's anywhere else you can suggest to look, I will post it.
Comment: Sorry, I should have specified that it was log entries `before` the CPU lockup was detected.
Comment: The last entry before the entries I pasted here were from about an hour and a half earlier (09:27:03) and was just saying that CONFIG_NF_CT_ACCT is deprecated and will be removed soon. Before that was 08:08:57, so over two and a half hours earlier. We were actively using the server for at least an hour and a half before we the 10:52 lockup, and it was working with no problems during that time.
Comment: Okay, so at this point you've done pretty much everything you can do from your end.  You *could* run `tcpdump` or `wireshark` to see if there are any obvious NFS or iSCSI errors or timeouts, but in that case your service provider's logs should show it too and don't require someone to be monitoring the network trace.
Comment: Frustrating....just got a message back from our provider, and they tell us that the problems shown in this log are a symptom of the load spike, not the cause of the load spike. Since I don't have any idea what could be causing this, I could be totally wrong here, but it seems to me like they're giving us the shaft here. If I just run `tcpdump` and let it sit there until the next time we see a lockup, would that give me any useful information? Any other instructions than just `tcpdump`? Sorry, I'm stumbling my way around already.
Comment: Problem is, so am I, since I'm not there.  :)  I would prefer `wireshark` over `tcpdump` if it's installed.  Set it to filter on the addresses of the NFS servers and iSCSI targets, so you're not inundated with traffic.  (Tracing the session over which you're running the network trace is a nice little self-DoS.  :)  Beyond that, well, we're both hunting for clues.  As to your provider, have they actually bothered to look at the logs or are they just blowing you off?  (On second thought, you probably can't answer that.)
Comment: Having a helluva time getting wireshark to work, so I will just run tcpdump if that's ok. Any special parameters that I should use with it? I will probably run it on Monday so that it doesn't run all weekend.
Comment: Something like `sudo tcpdump -i (interface) host (nfsserver) or host (iscsitarget) or ...`  I can't be more specific because, well, the specifics are what we're trying to find.
Comment: Thanks for your help, but it looks like we are going to hire a consultant. We really don't know what we're doing, not even enough to tell you if it even goes through NFS or iSCSI, let alone being able to find the NFS server or iSCSI target. It's pretty much all over our heads. I will definitely try to get info from the consultant as to what they think the problem is and I will post it here, probably some time next week. Thanks again for the help!
Comment: You're welcome.  (I noted NFS and iSCSI from the loaded kernel modules in your kernel error message, btw.)
Answer: In the end, the problem was actually hardware-related. We migrated to a different server and POOF, the problem is gone. At least it made us take a good hard look at possible performance issues in our own programs. We found a few things that would have probably gone unnoticed, but should be cleaned up.


Scaled Bitmap is failed in Samsung Galaxy S3

Question: Thanks for earlier support.
Currently I am working on a Project where i need to resize images downloaded from Server. Images have a large resolution so i want to resize as per screenSize of Device. Here below is my code. Please have a look.
<code>                    // decode image size initially
        BitmapFactory.Options o = new BitmapFactory.Options();
        o.inJustDecodeBounds = true;
        FileInputStream stream1 = new FileInputStream(f);
        BitmapFactory.decodeStream(stream1, null, o);
        stream1.close();

        // Find the correct scale value.
        int width_tmp = o.outWidth, height_tmp = o.outHeight;
        int scale = 1;
        while (true) {
            if (width_tmp / 2 < REQUIRED_SIZE
                    || height_tmp / 2 < REQUIRED_SIZE)
                break;
            width_tmp /= 2;
            height_tmp /= 2;
            scale *= 2;
        }

        // decode with inSampleSize
        BitmapFactory.Options o2 = new BitmapFactory.Options();
        o2.inSampleSize = scale;
        FileInputStream stream2 = new FileInputStream(f);
        Bitmap bitmap = BitmapFactory.decodeStream(stream2, null, o2);
        stream2.close();
</code>
But once i get the desirable scale it finds a null-bitmap at the end of the Code in case of Samsung Galaxy S3. It's working fine on Emulator, Samsung galaxy S4, Htc one v. I am also worried about generalization of the Code so it should be working on Every device.
If anybody had experience for such a Problem Please let me know.
Answer: what's your REQUIRED_SIZE value? set it 1024. Because may be that was due to Out of memory exception while decode large resolution image.
Comment: It's 720 in case of Samsung galaxy S3.


If $\|f(x)-f(y)\|\ge \alpha\cdot\|x-y\|$ and $g$ integrable $\Longrightarrow$ $g\circ f:A \longrightarrow \mathbb{R}$ is an integrable function

Question: Any idea about this problem:
Let $f:A\subset\mathbb{R}^m \longrightarrow B\subset\mathbb{R}^n$ continuous such that:
$\|f(x)-f(y)\|\ge \alpha\cdot\|x-y\|,\forall x,y\in A$ ($\alpha >0$ is a constant)
If $g:B \longrightarrow \mathbb{R}$ is an Riemann integrable function, prove that $g\circ f:A \longrightarrow \mathbb{R}$ is an Riemann integrable function.
Any hints would be appreciated.
Comment: A variant: [Measurability of the composition of a measurable map with a surjective map satisfying an expansion condition](http://math.stackexchange.com/q/33742). That $f$ is assumed to be surjective in that thread isn't used in a crucial way and integrability is easy as soon as you have measurability.
Comment: A possible duplicate of [this](https://math.stackexchange.com/questions/2463714/fx-fy-ge-cx-y-with-c0-then-for-gb-to-mathbbr-integrable-the) question.
Answer: I think the problem is wrong as stated. $A \subset \mathbb R^3$ the unit ball, $B \subset \mathbb R^2$ the disk of radius 1 billion, and $f: A \to B$ defined as
$$f(x_1,x_2,x_3)=(x_1,x_2) \, \mbox{ if $x_1$ is rational} $$
$$f(x_1,x_2,x_3)=(x_1+10, x_2)  \, \mbox{ if $x_1$ is irrational}$$
It is easy to check taht this function satisfies the above relation with $\alpha=1$..
If $g$ is continuous, typically $g \circ f$ is discontinuous at all points...
P.S. Are you talking about Riemann or Lesbegue integrability... My example only shows it is not Riemann integrable...
Comment: Sorry for the typo. I have just edited it.
Comment: This example doesn't satisfy the "expansion" condition.
Comment: @zhw. If both $x_1's$ are rational or irrational you get equality in the "expansion" condition. And if one is rational and the other irrational, the fact that $10$ is much larger than the diameter of $A$ gives immediately the expansion condition.
Comment: Don't we have $f(0,0,1/2) = f(0,0,0) = (0,0)?$


Mixin em LESS para a função "calc()" do CSS, como usar duas variáveis?

Question: Eu tenho este mixin que funciona perfeitamente:
.calcW(@valor2: 100px) {
    width: -o-calc(~"100% - "@valor2);
    width: -webkit-calc(~"100% - "@valor2);
    width: -moz-calc(~"100% - "@valor2);
    width: calc(~"100% - "@valor2);
}

Gostaria que no lugar do "100%" do código acima, eu pudesse colocar uma variável chamada @valor1, dessa forma eu teria um mixin que me ajudaria em todas as situações em que eu precisasse de calc(), porém, quando faço da forma abaixo ele não funciona.
.calcW(@valor1: 100%, @valor2: 100px) {
    width: -o-calc(~"@valor1 - "@valor2);
    width: -webkit-calc(~"@valor1 - "@valor2);
    width: -moz-calc(~"@valor1 - "@valor2);
    width: calc(~"@valor1 - "@valor2);
}

Eu já tentei de várias formas, várias combinações, mas nenhum funciona, como posso usar duas variáveis em uma função calc()?
Comment: Retire as aspas ("") da variável _@valor1_.
Comment: Foi a primeira maneira que tentei, não funciona.

Pro Less compilar o @calc, ele precisa ser escrito dessa forma:

http://stackoverflow.com/questions/17904088/disable-less-css-overwriting-calc
Answer: Use interpolação de variável. Exemplo:
.calcW(@valor1: 100%, @valor2: 100px){
   width: calc(~'@{valor1} - ' @valor2)
}

ou diretamente:
.calcW(@valor1: 100%, @valor2: 100px){
  width: ~'calc(@{valor1} - @{valor2})'
}

Comment: Funcionou diretamente apenas, mas somente com os dois pontos após a variavel **@valor1**.

`.calcW(@valor1: 100%, @valor2: 100px){
  width: ~'calc(@{valor1} - @{valor2})'
}`

@renan, muito obrigado!
Comment: @GuilhermeLaureano verdade, erro de sintaxe :D corrigido. A primeira forma é pra funcionar também, deu algum erro?
Comment: Aqui não compilou da primeira vez, mas testei de novo e deu certo, devo ter feito algo errado mas não faço ideia do que, rs.

Então, devo por os prefixos moz e webkit como eu havia feito antes? Se sim, como ficaria a sintaxe?
Comment: Da mesma forma que estava fazendo, a diferença é que usará a interpolação para referenciar a variável `valor1` com a sintaxe `@{}`. Uma parada mais interessante de fazer é definir esses prefixos em uma lista - já que serão sempre os mesmos. E então fazer um *mixin* genérico (que recebe uma propriedade e valor) e percorre a lista aplicando os valores de prefixo à propriedade. Less [suporta loops](http://lesscss.org/features/#loops-feature). **:D**


in search of a Formula for ratio where one element is 0

Question: Very nice to meet you all. I am searching to find the value x for the given image. its a ratio that looks like this:
0: 1 = 350 : Y

but this leads if we solve for Y:
0 * Y = 350 * 1

Y = 350/0

which is undefined.

How can i get the Y value in such a case for this ratio ?
UPDATE: THE 0 in the image represents an offset start. so i am giving an offset from 0 to 1 (or if you like 0% to 100%).   the orange numbers is my new offset i have created, it runs from 350 to Y.
UPDATE2:

There is this green box that i can drag up and down...
when this green box is collapsed as it is now in the below image near                                     the bottom, the dragOffset is defined as 0. so to be clear, collapsed box has offset of 0 ALWAYS.
as the box gets dragged towards the top, the offset keeps increasing from 0 until finally it hits the top which is a max offset of 1. So to be clear, the dragging offset from collapsed to expanded is numbers between [0,1].
Here is the image so you can see the transition. how the dragOffset is being delivered to me:

I have the ability to make the greenbox 60% of the total height like this:

but when it reaches 60% the system is giving me a value such as 0.6 for the top, But at this point i can consider 60% as the FULL HEIGHT.  So the system thinks the full height is 1 but i want the full height to be at 0.6 (or 60%) mark
**so to be clear, i am searching for a way to SCALE the dragOffsets values called Y1,Y2,Y3,Y4,Yz  such that dragging from 0 to 0.6 would be the same as dragging from 0 to 1 in the system.  Hope it's clear now .
Comment: 0 and 1 seem to be points; what are 350 and Y ?
Comment: $\dfrac 0 1 = \dfrac {350}{y}$ is undefined because there is no value for $y$ such that $0 y = 350$.
Comment: The picture is really odd: Something in the lower corner is $0$, and in the upper corner it's $1$. What is this something? Where did you get this picture? Did you make it yourself? If you made it yourself, perhaps it would be a good idea to make a clearer picture.
Comment: i updated the comments in a update section.
Comment: Could you explain why you want to calculate this? What is the context, and what is it that you need to calculate exactly? Also, in the picture, it's not really clear what the relationship between the distances is. The $Y$ and $350$ seem to be just floating in random spots ...
Comment: ok, wait a while let me create another image to explain it.
Comment: i made some updates to show what i need
Answer: I think you want to map the interval $[0,1]$ to the interval $[350,Y]$.
The scale factor of your mapping is given by $\frac{Y-350}{1-0}=\frac{Y-350}{1}$, but you can't work out $Y$ without some more information about your new interval.
Comment: can you check my latest update to see if it helps, yes i want a scale factor i can apply to Y
Comment: I'm still struggling to understand what you mean.


How to pass a reference to a variable to a method - not the value of a variable - in VueJS

Question: In my template I have this:
<input @input="myMethod(myVariableName)" />

Then I have myMethod
myMethod(variablePassed) {
  console.log(variablePassed)
}

What I receive is the value of the "variablePassed" (of course). But, is there a way for me to see which variable got passed?
Comment: No. A function call is evaluated by first completely evaluating the argument expressions. Once that's done, all that's left of each argument expression is its value.
Comment: What are you trying to achieve by knowing the name of the variable?
Answer: Yes you could do that by passing the variable wrapped inside a literal object {} and use Object.keys(varname)[0] to get its name and Object.values(varname)[0] to get its value:

Vue.config.devtools = false;
Vue.config.productionTip = false;

new Vue({
  el: '#app',

  data() {
    return {
      name: "john"
    }
  },
  methods: {
    myMethod(variablePassed) {

      console.log(Object.keys(variablePassed)[0])
       console.log(Object.values(variablePassed)[0])

    }
  }
})
#app {
  padding: 20px;
}
<link type="text/css" rel="stylesheet" href="//unpkg.com/bootstrap/dist/css/bootstrap.min.css" />

  <input @input="myMethod({name})" class="form-control" />

Comment: ah ok in this case you couldn't
Comment: no problem. But your example above with a simple variable worked fine.
Comment: This is great. Do you see a way to pass a variable nested in an object? If "name" was an object with nested "firstName" for example?

"name.firstName"
Comment: i didn't understand what you want exactly ?
Comment: If the "name" variable was an object >> name: { first: "john", last: "Jackson" } and you wanted to pass "name.first" to the method.
Comment: could you explain more your use case? i hope that i could help you


R inspect() function, from tm package, only returns 10 outputs when using dictionary terms

Question: I have 70 PDFs of scientific papers that I'm trying to narrow down by looking for specific terms within them, using the dictionary function of inspect(), which is part of the tm package. My PDFs are stored in a VCorpus object. Here's an example of what my code looks like using the crude dataset and common terms that would show up in (probably) every example paper in crude:
library(tm)
output.matrix <- inspect(DocumentTermMatrix(crude,
                                      list(dictionary = c("i","and",
                                                          "all","of",
                                                          "the","if",
                                                          "i'm","looking",
                                                          "for","but","because","has",
                                                          "it","was"))))
output <- data.frame(output.matrix)

This search only ever returns 10 papers into output.matrix. The outcome given is:
Docs  all and because but for has i i'm the was
  144   0   9       0   5   5   2 0   0  17   1
  236   0   7       4   2   4   5 0   0  15   7
  237   1  11       1   3   3   2 0   0  30   2
  246   0   9       0   0   6   1 0   0  18   2
  248   1   6       1   1   2   0 0   0  27   4
  273   0   5       2   2   4   1 0   0  21   1
  368   0   1       0   1   0   0 0   0  11   2
  489   0   5       0   0   4   0 0   0   8   0
  502   0   6       0   1   5   0 0   0  13   0
  704   0   5       1   0   3   2 0   0  21   0

For my actual dataset of 70 papers, I know there should be greater than 10 because as I add more PDFs to my VCorpus, which I know contain at least one of my search terms, I still only get 10 in the output. I want to adjust the outcome to be a list, like the one shown, that gives every paper from the VCorpus that contains a term, not just what I assume is the first 10.
Using R version 4.0.2, macOS High Sierra 10.13.6
Comment: @starja tm, it was named in the body of the post but not the title, which has now been updated
Comment: From which package is `inspect`?
Comment: Please specify the package `tm` in your post
Answer: You are misinterpreting what inspect does. For a document term matrix it show the first 10 rows and columns. inspect should only be used to check your corpus or document term matrix if it looks as you expect. Never for transforming data to a data.frame. If you want the data of the document term matrix in a data.frame, the following piece of code does this, using your example code and removing all the rows and columns that don't have a value for any of the documents or terms.
# do not use inspect as this will give a wrong result!
output.matrix <- DocumentTermMatrix(crude,
                                    list(dictionary = c("i","and",
                                                        "all","of",
                                                        "the","if",
                                                        "i'm","looking",
                                                        "for","but","because","has",
                                                        "it","was")))

# remove rows and columns that are 0 staying inside a sparse matrix for speed
out <- output.matrix[slam::row_sums(output.matrix) > 0,
                     slam::col_sums(output.matrix) > 0]

# transform to data.frame
out_df <- data.frame(docs = row.names(out), as.matrix(out), row.names = NULL)

out_df
   docs all and because but for. has the was
1   127   0   1       0   0    2   0   5   1
2   144   0   9       0   5    5   2  17   1
3   191   0   0       0   0    2   0   4   0
4   194   1   1       0   0    2   0   4   1
5   211   0   2       0   0    2   0   8   0
6   236   0   7       4   2    4   5  15   7
7   237   1  11       1   3    3   2  30   2
8   242   0   3       0   1    1   1   6   1
9   246   0   9       0   0    6   1  18   2
10  248   1   6       1   1    2   0  27   4
11  273   0   5       2   2    4   1  21   1
12  349   0   2       0   0    0   0   5   0
13  352   0   3       0   0    0   0   7   1
14  353   0   1       0   0    2   1   4   3
15  368   0   1       0   1    0   0  11   2
16  489   0   5       0   0    4   0   8   0
17  502   0   6       0   1    5   0  13   0
18  543   0   0       0   0    3   0   5   1
19  704   0   5       1   0    3   2  21   0
20  708   0   0       0   0    0   0   0   1

Comment: This works for transforming the matrix to a dataframe, but I am looking for a solution to only getting 10 outputs. If ```inspect``` only shows the first 10 rows and columns, what should I use to pull out all of the documents out of my 70 that contain at least one of the given phrases?
Comment: @millie0725, If this is not what your are looking for, please create an expected output using the crude dataset.
Comment: I updated my original example code above to include an expected output with the crude dataset.


node preview button not working

Question: The issue I am having is that when I try to preview the content of a node I have created by clicking the 'Preview' button the page just refreshes and the preview.
What I have tried

Looking into permissions to do with viewing unpublished content.
Comment: Did you suggest any theme hook for the content type of that node ?
Answer:
Your site local or not? Can you give a link?

You use standart theme or custom?

Try to edit node type configuration → http://somesite.ltd/admin/structure/types/manage/content_type_machine_name. Before open link you must change somesite.ltd & content_type_machine_neme

node preview button not working