Category Archives: computing

how to use xmlns prefix with xsl transformation

XSL transformation was working with an xml file without any explicit xmlns namespace, but failed on file with explicit namespace such as in below code: <FpML xmlns=”http://www.mynamespace” xmlns:xsi=””> Reason is because by default, XSL version 1.0 is considering default namespace to be blank. As such, in order to match a file with explicit namespace, possibilities are: remove namespace from input file change xsl by: adding a namespace prefix in header that is matching the input namespace <xsl:stylesheet xmlns:xsl=”” version=”1.0″> now becomes: <xsl:stylesheet xmlns:t=”http://www.mynamespace” xmlns:xsl=”” version=”1.0″> prefix all nodes used in xpath requests with previously defined prefix <xsl:param name=”data” select=”/FpML/dealEntry/eventAction” /> […]

plymouthd crashed with sigsegv in script_obj_deref_direct() [SOLVED]

I had this crash report upon booting my up-to-date ubuntu. In order to remove this: edit /etc/default/grub: sudo vi /etc/default/grub comment out line: #GRUB_CMDLINE_LINUX_DEFAULT=”splash plymouth:debug” add new line: GRUB_CMDLINE_LINUX_DEFAULT=”splash plymouth:debug” reboot grub: sudo update-grub That’s it. It is supposed to activate debugging and log info into /var/log/plymouth-debug.log. Which it does, but it also got rid of the error. sources

flask + apache + mod_wsgi – not working [solved]

Gosh! it took me a whole day to identify what the issue was…. Basically what is happening: when using WSGIScriptAlias directive on non-root url (i..e you’re not matching “/”), mod_wsgi strip the url of the matched part Here is an example: in htttpd.conf: WSGIDaemonProcess credmanager user=myuser group=mygroup threads=5 python-home=/path/to/virtualenv WSGIScriptAlias /api /var/www/credmanager/api/credmanager.wsgi WSGIProcessGroup credmanager WSGIApplicationGroup %{GLOBAL} WSGIPassAuthorization On <Directory /var/www/credmanager> Options FollowSymLinks Require all granted </Directory> In above example, we are only handling via python uris starting with “/api”. Let’s say requested url: => url is starting with “/api” so it is matched and handled by mod_wsgi => python […]

angular2 – ‘this’ binding context lost in .catch call

I noticed that “this” was undefined when calling .catch method: return this.http .get(‘/api/misc-url’) .toPromise() .then(response => response.json()) .catch(this.handleError); It happens that this is happening because of the way function is called in .catch. By providing directly the method, we are losing context. By wrapping call into arrow function we can restore it! (better than .bind(this) :)) return this.http .get(‘/api/misc-url’) .toPromise() .then(response => response.json())         .catch(error => {this.handleError(error); }); Easy 🙂 sources  

unix – list content of tar file and extract specific file

To list content of tar.gz file: tar -tvf my-data.tar.gz ‘<looked-for-file-or-path-name>’ To extract specific cotnent from tar.gz file: tar -xvpBf my-data.tar.gz ‘<path-name>’ sources

creating a python virtual environment

When starting a new python project, it is usually sound practice to use a dedicated virtual environment. By doing so your project is isolated from other applications using python and all dependencies can be properly tracked. ensure python is installed ensure pip is installed (note: starting python3.4, pip is installed by default) ensure virtualenv is installed (note: starting python3.3, venv is installed by default) In a nutshell, if you have python >= python3.4, nothing to install!! Easy 🙂 Run below commands: cd <path/to/my/project> python3 -m venv ./virtualenv Done. Run source ./virtualenv/bin/activate to activate your virtual environment sources

Feed unix pipe into ls / feed ls with pipe

To feed “ls” instruction with pipe, simply use xargs as per below: find . -type f -name mypattern* | xargs ls -l sources

unix – split large text file into smaller one

run: split -a 5 -d -l 10000 my_file.txt my_file_ usage: split -a 5 -d -l <nb_lines_per_file> <file_to_split> <split_prefix> d = numeric numbering (instead of alphabetical) l = number of lines per split files a = number of characters used for numbering (increase it in case of exhaustion) sources

oracle – apply query to multiple tables

Let’s say you want to grant rights on a set of tables to a given user, here is how to do it: begin for c in ( select ‘grant select on ‘||owner||’.’||table_name||’ to newuser’ cmd from all_tables where owner = ‘myowner’ and table_name like ‘TABLE_NAME_%’ ) loop execute immediate c.cmd; end loop; end; / Note: same logic can be extended to apply any type of query to multiple tables

unix – compare folder tree and identify files which are different

Very easy: sources diff -arq folder1 folder2