POP Keywords: apache oracle sybase ...

unix – run/send process in the background

Below are a few ways of achieving that Option1: nohup With nohup (no-hangup): nohup <command-line> > <to_file.out> & (use >> to append) Option 2: pause/restart as background process Issue is when you need to provide some user inputs. In that case, proceed as follows: Run CLI as per normal and provide required user input Once no more input is required, hit ctrl+Z to stop/pause the job Run following command to identify your job id (different from pid): jobs Note: in above screenshot my job_id would be “1” Disown the process: disown -h %<job_id> Note: “%” is required Resume process: bg […]

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=”http://www.w3.org/2001/XMLSchema-instance”> 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=”http://www.w3.org/1999/XSL/Transform” version=”1.0″> now becomes: <xsl:stylesheet xmlns:t=”http://www.mynamespace” xmlns:xsl=”http://www.w3.org/1999/XSL/Transform” 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 https://askubuntu.com/questions/864242/plymouth-error-logging https://wiki.ubuntu.com/Plymouth#Debugging https://bugs.launchpad.net/ubuntu/+source/ubuntu-gnome-default-settings/+bug/1536771

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: http://www.mydomain.com/api/toto => 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 http://stackoverflow.com/questions/36227996/angular2-getting-confused-with-observable-catch-closure-scope  

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 https://www.cyberciti.biz/faq/list-the-contents-of-a-tar-or-targz-file/

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 https://docs.python.org/3/library/venv.html#module-venv

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 http://stackoverflow.com/questions/18210956/unix-pipe-into-ls

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 https://kb.iu.edu/d/afar

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