About jontas

I like to make things that people find useful.

Kill all processes with a given name

suppose we wish to kill all instances of rsync that is running
Simplest given that we know the process name

pkill rsync
ps aux|awk '/sleep/ {print "kill -9 " $1}'

Or a sligtly longer version that might(?) be more verbose as to what it does

kill -9 $(ps aux | grep '[r]sync' | awk '{print $2}')

un tar and ownership of the extracted files

If the user extracting is a “ordinary” user, the files will be owned by that user (by default).
If the user extracting is a super user, then the files ownership will be preserved (by default).

Note: This is by default and can be overridden when needed:

From the manual page of tar:

--same-owner
       try extracting files with the same ownership as exists in the archive (default for superuser)
 
--no-same-owner
       extract files as yourself (default for ordinary users)

Sony Smart Extras (Smartwatch) When using an .xml file to specify the layout of an accessory, remember the following

  • All sizes should be expressed in px. This to avoid scaling based on the phone density.
  • If an ImageView is used to show an image, we recommend that you specify layout_width and layout_height in px to avoid scaling based on the phone density.

Note: This is since the phone density is based on the phone (or tablet) you have connected the smart extension to, not the smart extension itself.

Sony Smartwatch Accelerometer sensor when is a axis positive (witch side is up)?

For the axis the values are:

  Positive value Negative value
x: The button is up The button is down
y: The Sony label is up The Sony label is down
z: The Screen is down The screen is up

Also a interesting thing to note, no matter how we all try to (when having the accelerometer using the SENSOR_STATUS_ACCURACY_HIGH) we can not get it to go past 78,15m/s^2.

Courage is facing the challenge with a healthy fear not being fearless!

“The way to survival whether you’re the victim or the rescuer, is through the path of methodical caution a calming of the spirit, mind and careful planning of your every move. Courage is facing the challenge with a healthy fear not being fearless. More than anything else making it through a horrendous ordeal requires the will to live if you expect to survive.”
-Les Stroud. (Used as a voice over at the end of S3E1 Sierra Nevada when Les Stroud was “rescued”).

Using RedirectToAction

The RedicrectToAction simply generates a HTTP 302 code witch tells the browser to get the next page.
It is important to remember that when this is used inside a view then we should return RedicrectToAction. This will render the View to the client (and make it redirect) and will stop any further execution (if the RedirectToAction for instance is inside a if statement)

public ActionResult Upload(UploadOrderModel uploadorder)
{
	if (uploadorder.IsInvalid)
	{
		//somthing fishy is going on ...
		return RedirectToAction("Index", "Home");
	}
	//do important things here
	return View(orderInfo);
}

system.web.mvc.controller.redirecttoaction at msdn

Force a span to honor a width

A span is normally a inline element so setting a width to it might not have the effects you are looking for.
In order to “force” a span to have a width it can be set as a inline-block

<span style="display:inline-block;width:92px;">&nbsp;</span>

another (better!) way is to use padding to give the span a size.

<span style="padding: 10px 20px; font-size: 0px;">&nbsp;</span>

(The font-size is here to “fix” the height of the span; and don’t forget that padding happens on both sides in this example so the end result is 20x40px)