Swissbytes
Samstag, 9. Juni 2018
How I backup my Synology NAS using rsync
I added this in /etc/crontab to start the backup daily. Note how I use the flock command to ensure that only a single instance of the backup is running. It is important to put the lockfile in a location other than /tmp.
Finally, I need to make sure that the logs do not overflow. To that end, I created this file in /etc/logrotate.d
Montag, 13. November 2017
Service Now Script Includes: Make sure to convert object references to values
Because I want to have a clean design, I try to use System properties. This gives me flexibility and clarity over strange literals like
var group_sys_id = "690acf664fc51200d4a679a18110c746" ;Instead I write
var group_sys_id = gs.getProperty("inc.assignment.group.default") ;Even if you have never seen one of my instances, it will be clear from the code above that the property defines the sys_id of the default assignment group.
Sometimes, you have to deal with a list of properties and you might not know initially how many there are. An example we encountered: the customer wants to send out notifications for expiring firewall rules. Currently, there are notifications to send 30, 14 and zero days prior to expiry.
The worst solution for this would be to add 3 columns to the table where said firewall rules are stored and put the actual notification dates there.
This is bad on many levels:
- It is a violation of good database design practise (Violation of the 1st Normal Form)
- It leads to a loss of flexibility (only an admin can add more notifications)
- You assume that there will always be three notifications
- sc.firewall.notify.days.1
- sc.firewall.notify.days.2
- sc.firewall.notify.days.3
All very well, now I just need a function (in a script include) to return these values.
How not to do it
My first attempt looked simple enough: But when I tested it (you always do that, right?), I was surprised (running this in a background script).var Toolbox = new Toolbox_Functions()Whoa what's that?
var res= Toolbox.getPropertyList("sc.firewall.notify.")
gs.print(res);
[0:00:00.002] Script completed in scope global: script
*** Script: sc.firewall.notify.3,sc.firewall.notify.3,sc.firewall.notify.3
Fixing the Problem
This is not a problem with Service Now, but a problem with JavaScript (or even Object-Oriented programming). The reason for this behaviour is that property_gr.name (line 23) contains an object reference and it will always point to the last element read (that is why we get the third entry three times)GlideRecord to the rescue: Service Now has added the function getValue(), well, to get the value (instead of the default object reference).
Another approach would be to use
arr.push(property_gr.name.toString());
or
arr.push(String(property_gr.name));
Recommended Reading
Samstag, 15. April 2017
Book review - The Peter principle by Laurence J Peter and Raymond Hull
This is the first installment of a new section of my blog - the review of vintage books.
“The Peter Principle” is known by many, but few have taken the time to actually look at the book that defines the principle. This volume, written in 1969 by journalist Raymund Hull as a popular account of the work of Laurence J. Peter is a fascinating piece of work. Much to my surprise, this book is very tongue-in-cheek and full of self-criticism.
On the surface, the book is based on this idea:
Every employee tends to be promoted until the individual level of incompetence is reached.
Starting from this statement, a wohle new science (the so-called “hierarchology”) is developed and many interesting “real-life” examples are presented.
Great examples include the “flying T-Formation”, where 23 vice presidents lead 3 divisions, the “free floating apex” where “a director is in charge of a non-existing department” or the most modern hierarchy of all where the computer replaces all lower ranks and only managers would remain.
Many examples can be found in real life - my favorite example is the “lateral arabesque”, where a manager is moved out of the way and given a much longer, important-looking job title.
The authors also provide guidance on how to avoid the trap of the principle - for example by developing some eccentric traits, such as leaving all drawers on ones office open when leaving in the evening.
Ultimately, the book has a far wieder scope - Peter and Hull are concerned about mankind as such and urge the reader to prevent our race from begin promoted to far (into oblivion). Here, they speak of “life competence”, which we as a race must retain.
A weak point of the book is its latent sexism. In this aspect, the book seems dated, while the book is modern in most other aspects.
The end of the book is symptomatic of the theme: Peter asks if somebody is willing to fund a professors post for him (because he has proven competent at the PhD level). This humorous self-criticism is a very strong aspect of this book.
Samstag, 19. März 2016
Code to check if your Email Adresses where compromised
What to do if an address of yours was compromised?
This could mean two things: either the actual Email-account is compromised (really bad) or some web account where this Email address was used is compromised (badness depends on if the service is critical AND if the same password was used elsewhere). I recommend the following:- Immediately Change the Password of said Email-Account
- Change the password of all accounts where the Email address is used as a password
Donnerstag, 10. März 2016
Moving Contents of subdirectories in a Windows batch or on the command line
@echo off
for /d %%d in ("*") do (
for /d %%e in ("%%d\*") do (
move "%%e" .
)
)
Note: this code only works for subdirectories. If the yearly folders directly contain files, they will not be copied.
In this case, use this code:
@echo off
for /d %%d in ("*") do (
for /d %%e in ("%%d\*") do (
move "%%e" .
)
move "%%d\*" .
)
Thanks a lot, Rik!
Mittwoch, 7. Januar 2015
Open Access gains momentum
Open access (OA) means unrestricted online access to peer-reviewed scholarly research. Open access is primarily intended for scholarly journal articles, but is also provided for a growing number of theses, book chapters, and scholarly monographs. Open access comes in two degrees: gratis open access, which is free online access, and libre open access, which is free online access plus some additional usage rights. These additional usage rights are often granted through the use of various specific Creative Commons licenses. Only libre open access is fully compliant with definitions of open access such as the Berlin Declaration on Open Access to Knowledge in the Sciences and Humanities.On the one hand, the article acknowledges that OA is seen as a new market, in which both new and old players thrive. Also, scientific and porfessional societies (such as IEEE or ACM) play an important role to propagate OA. Not to be neglected is the power of funding agencies, where for example the EU plays an important role.
(Open access. (2015, January 6). In Wikipedia, The Free Encyclopedia. Retrieved 10:44, January 7, 2015, from http://en.wikipedia.org/w/index.php?title=Open_access&oldid=641177048)
Mittwoch, 2. Juli 2014
A completely new approach to where we come from
It turns out that this notion recently got competition by a revolutionary new hypothesis which at first sounds quite strange, but then is really compelling. As Eugene M. McCarthy explains comprehensively on his page, he proposes the hypothesis that humans are a so-called backcrossed hybrid. So rather than slowly evolving from a single species, according to this hypothesis, human beings might be a cross of two completely different species which then repeatedly mated with one of the ancestors. One of these ancestors he calls chimpanzees (however he states "here, I use the term chimpanzee loosely to refer to either the common chimpanzee or to the bonobo, also known as the pygmy chimpanzee; the specific roles of these two rather similar apes within the context of the present hypothesis will be explained in a subsequent section".
After having read the extremely interesting book "Sex at dawn" by Ryan and Jetha (I know the title is cheesy), I think it is prudent to believe that the bonobo is one of the ancestors. Then he addresses the question of which animal might be the second ancestor. He does this by meticulously listing (a subset) of the features found in humans but not in chimpanzees and then seeks to find an animal that has all of these features.
Lets try it:
- Intelligent
- Naked skin
- Eyes in different colors, including blue
- Protruding nose (made of cartilage)
- Eyebrows and Eyelashes present
- Good swimmer
- Eats a large variety of food
- Humans are not very fertile, especially male sperm is often degenerate. This is common for hybrid mammals
- Pigs are indeed very intelligent
- Pigs have a cleft lip - something that never occurs in apes but may occur in humans
Thank the Pig by Gene McCarthy
Not everyone will say it's true,
But pigs are creatures much like you.
We ape an ape in many ways,
Yet pig distinctions win our praise.