Adding system accounts

Some user accounts are used for running system services so they cannot interfere with files outside their user space. To create a system account, do the following:

useradd -r <username>

This creates a user with no password, and no home directory. You can optionally create a home dir by supplying the -m option.

useradd -r <username> -m

Simple upstart script

All upstart scripts must be placed in

etc/init/

and must be owned by root. The script filename must end in .conf

A simple upstart scrip can look like this

start on startup
setgid foo
setuid foo
respawn
respawn limit 15 60
exec <my-app>
start on startup

This entry tells upstart to run the application on startup. This can be a run-level specification as well.

setgid foo
setuid foo

Sets user and group id if needed.

respawn
respawn limit 15 60

Upstart will restart the application if it dies, but will stop if if restarts 15 times within 60 seconds.

authbind. Using priviledged ports in non-priviledged applications

Install authbind.

Create a file in

/etc/authbind/byport

with the port-number you wish yo expose. For example, to expose port 80, create the following file:

/etc/authbind/byport/80

Change the user of the file to the user the application is running as, and change the access rights to 755.

Now, run the application like this:

authbind <my-app>

The application now has access to port 80, without requiring sudo rights to run! Authbind can optionally be run with the –deep parameter, to allow all sub-processes access to the port as well.

Chili Chutney

  • 2 hele hvidløg
  • 1 løg
  • 1 dåse hakkede tomater
  • 1 lille dåse tomatpuré
  • 1 pose (150g) soltørrede tomater
  • chili efter smag. Mindst en håndfuld
  • 4 store spiseskeer brun farin
  • 1 sjat æblecidereddike (1/2 – 1 dl, efter smag)
  • Salt. ca. 1 teskefuld. Efter smag. Kan undlades.

Procedure:

  1. Pres hvidløg i presser.
  2. Hak løg fint
  3. Hak chili fint, med kerner og det hele
  4. Svits løg og hvidløg i olivenolie, til hvidløgene begynder at blive lidt lyst brune. Ikke ved fuld varme. Det brænder hurtigt på.
  5. Tilsæt tomatpuré og rør rundt, og lad tomatpurén svitse lidt.
  6. Tilsæt hakkede tomater, chili, soltørrede tomater, brun farin og æblecidereddike. Lad stå og simre ved svag varme i ca 30. minutter.
  7. Lad stå og køle af. Når temperaturen er nede ved håndtemperatur, gives hele blandingen en tur i blender eller med stavblender til chutneyen har den ønskede konsistens.
  8. Smag til med salt.

Javascript self-invoking functions

Example of a self-invoking javascript function. Notice the parenthesis around the entire function declaration.

(function() {
    var foo = 20;
})();

The parenthesis around the function exist to differentiate it from an actual function definition. It would not be possible to auto-invoke it with the () at the end.

Another syntax for self-invoking functions is also available:

! function() {
    var foo = 20;
}();

Again, the ‘!’ is there to show that its not a function declaration.