POP Keywords: apache oracle sybase ...

python lxml – use absolute xpath to find elements [solved]

When using lxml library, using an absolute xpath such as ‘/root/child/other_child’ end up with a nasty error message: SyntaxError: cannot use absolute path on element Reason for that is that call was performed on an Element using .findall() method. To use an absolute xpath, do not perform call on an Element, rather perform call on an ElementTree and call .xpath() method instead of .findall() Illustration below: etree.parse(fpath).getroot().findall(‘/root/child/’) # => SyntaxError: cannot use absolute path on element etree.parse(fpath).xpath(‘/root/child/’) # => OK sources http://stackoverflow.com/questions/16367504/python-parsing-html-elements-based-on-absolute-xpath http://lxml.de/api/

apache – grant access to single file

Steps Ensure target file has read access from apache user ls -l /path/to/my/file/myfile.doc If not, grant right via: chmod a+rwx /path/to/my/file/myfile.doc In one of your /etc/apache/sites-enable/*.conf files, add the following: <Directory /path/to/my/file> <Files myfile.doc> Require all granted </Files> </Directory> Restart apache sudo apache2ctl restart Voilà! sources http://stackoverflow.com/questions/13799932/how-to-allow-access-to-only-a-single-file

ubuntu with gnome 3 – change login screen logo [solved]

To change login screen logo on ubuntu with gnome 3, proceed as follows: sudo apt-get install dconf-editor open dconf-editor as root: sudo dconf-editor navigate to org > gnome > login-screen update value of “logo” variable to the path of logo file to use restart GDM And voilà! sources http://ubuntuhandbook.org/index.php/2014/04/ubuntu-14-04-change-login-screen-background-remove-the-white-dots/ http://stackoverflow.com/questions/29189648/why-cant-i-change-the-gnome-login-screen-logo  

ubuntu – install all google fonts and use them in gimp

To install all google fonts in gimp on ubuntu, proceed as follows: download fonts from https://github.com/google/fonts/archive/master.zip create a folder “.fonts” in your home directory: mkdir ~/.fonts unzip content of downloaded file into newly created .fonts folder: cd ~/.fonts; unzip ~/Downloads/master.zip regenerate font cache: sudo fc-cache -fv restart gimp That’s it. All fonts should be avaialable sources https://github.com/google/fonts/ http://askubuntu.com/questions/3697/how-do-i-install-fonts https://wiki.ubuntu.com/Fonts https://www.google.com/fonts

gnome – change default screenshot program

Default screenshot program is easy to use and does the job. If you want to go slightly forward, such as selecting screenshot area, editing screenshot and so on, you should give a go to “shutter” as an alternative. steps install shutter: sudo apt-get install shutter set up shutter as default application go to keyboard shortcuts under tab “Customs Shortcuts” create a new shortcut running “shutter -s”, as per below assign the print-screen button as activation button for this shortcut, as per below done! sources http://askubuntu.com/questions/252717/how-to-make-shutter-as-the-default-screenshot-tool  

gnome 3 – default theme – header way too big [solved]

To reduce window header: create a file under vi ~/.config/gtk-3.0/gtk.css enter following css content (customize padding values and font sizes as required): .header-bar { padding-top: 1px; padding-bottom: 1px; font-size: 7px; } .header-bar .button { padding-top: 1px; padding-bottom: 1px; } .header-bar.default-decoration { padding-top: 1px; padding-bottom: 1px; border: none; background-image: linear-gradient(to bottom, shade(@theme_bg_color, 1.05), shade(@theme_bg_color, 0.99)); box-shadow: inset 0 1px shade(@theme_bg_color, 1.4); } .header-bar.default-decoration .button.titlebutton { padding-top: 1px; padding-bottom: 1px; } Witness the impact live by restarting gnome shell: alt+f2 then run “r” And voilà! To go further: run “gnome-tweak-tool” under section “fonts”, reduce various font sizes and play with “scaling factor” […]

sick of nautilus opening target folder when moving files, switching to nemo

To switch to nemo file-manager, proceed as follows: Install packages: sudo apt-get install nemo nemo-fileroller Activate nemo: sudo xdg-mime default nemo.desktop inode/directory application/x-gnome-saved-search sudo gsettings set org.gnome.desktop.background show-desktop-icons false sudo gsettings set org.nemo.desktop show-desktop-icons true Ensure nemo was activated properly: xdg-mime query default inode/directory nemo.desktop sources http://askubuntu.com/questions/481742/how-to-replace-nautilius-with-nemo-in-gnome-3

unix – find all files in folder with or without size

To find all files (without following symlinks): find -P . -type f To find all files along with their corresponding size in bytes: find -P . -type f -exec stat -c ‘%s      %n’ {} \; sources http://askubuntu.com/questions/460210/using-find-and-stat-to-display-filenames-and-statistics

Unix – find files modified on a specific date / between two dates

“find” command is our friend here, using “-newer” argument. This is a 2-step process: create reference file(s) with required date limit(s) run find command with reference to this/these file(s) find all files modified after 2015/12/15 6:51pm and 2 seconds touch -t 201512151851.02 /tmp/t find . -newer /tmp/t find all files modified between two dates touch -t <date1> /tmp/t1 touch -t <date2> /tmp/t2 find . -newer /tmp/t1 -and -not -newer /tmp/t2 sources http://stackoverflow.com/questions/158044/how-to-use-find-to-search-for-files-created-on-a-specific-date

oracle – truncate tables based on select query

PL/SQL allows to execute sql statements using a FOR loop, looping through results of another query. In below example we truncate all tables returned by another query: — Q1: empty all audit tables –/ BEGIN — Disable constraints — Truncate tables returned by SELECT query FOR entry IN ( SELECT table_name FROM user_tables WHERE table_name like ‘%AUDIT%’ — and rownum < 3 order by table_name ) LOOP –EXECUTE IMMEDIATE ‘select * from ‘ || entry.table_name || ‘ where rownum < 10’; EXECUTE IMMEDIATE ‘truncate table ‘ || entry.table_name; END LOOP; — Enable constraints END; / Note: make sure to enclose […]