I kept thinking this would be fixed, I finally had to look up a workaround. When using KDE, LibreOffice simply crashes when attempting to save a new document (at least in Writer). This has to be the worst possible bug, you work on the document get it to the point you want it, then lose everything and it has been happening for quite some time.
The bug is apparently in KDE's dialog boxes and can be worked around by selecting "Use LibreOffice Dialogs" under Tools->Options->General.
Found on askubuntu
Tuesday, December 31, 2013
Wednesday, December 18, 2013
When to use attributes in XML
Its not rocket science but I guess I thought there was some general school of thought on this subject.
But I like this idea from w3schools which is to basically avoid attributes except for possibly an ID field.
But I like this idea from w3schools which is to basically avoid attributes except for possibly an ID field.
Tuesday, December 17, 2013
rename command in Arch
I couldn't figure out why my rename command wasn't working in Arch, and it slowly dawned on me that the rename command in Arch doesn't support regular expressions... making it almost completely useless.
After some searching I found this blog entry that confirmed my suspicions and pointed me to an AUR package that basically implements rename with regular expressions.
Replace spaces with underscores in all files.
After some searching I found this blog entry that confirmed my suspicions and pointed me to an AUR package that basically implements rename with regular expressions.
$ packer -S rename
$ renamexm -s/\ /_/g *Replace spaces with underscores in all files.
Thursday, December 12, 2013
Comparing contents of files
Apparently the diff command can be used for comparing the contents of two folders.
This LinuxCommando post gives the details.
This LinuxCommando post gives the details.
$ diff folder1/ folder2/
Indenting code with vim
This stackoverflow post has a wealth of information about indenting, and particularly indenting code blocks in vim.
Though the block indent stuff doesn't seem to work with shell scripts, the re-indent entire buffer command does:
Though the block indent stuff doesn't seem to work with shell scripts, the re-indent entire buffer command does:
gg=G
Wednesday, December 4, 2013
Bash snippets
I guess I will continue my current trend of having a single post be a clearing house for tips relating to a specific language.
Printf
Echo list of folder names
Iterating through a file line by line
Or as a one liner (even works if lines have spaces)
Dereference variables
$ var="Hello" && echo ${var:1:3}
ell
$ basename $FILE
path.txt
$ dirname $FILE
$ echo "${FILE##*/}"
path.txt
Math
$ x=0; let x+=3; let x-=1; echo $x
2
Generate range of numbers
$ for i in {1..5}; do echo -n $i; done
12345
Alternatively
$ for i in $(seq 1 5); do echo $i; done
12345
2
Generate range of numbers
$ for i in {1..5}; do echo -n $i; done
12345
Alternatively
$ for i in $(seq 1 5); do echo $i; done
12345
Iteration, etc...
Change password expiration data
$ chage -d now user
Printf
$ printf "%02d %02d\n" 5 6
05 06
05 06
Echo list of folder names
$ echo */
home/ Desktop/ ...
Iterating through a file line by line
IN_FILE=$1
OUT_FILE=$2
<!-- Add a generated password to end of line -->
while read s; do
echo "$s, `apg -n 1`" >> $OUT_FILE
done < $IN_FILE
OUT_FILE=$2
<!-- Add a generated password to end of line -->
while read s; do
echo "$s, `apg -n 1`" >> $OUT_FILE
done < $IN_FILE
Or as a one liner (even works if lines have spaces)
$ while read s; do echo "$s"; done < broke.txt
Dereference variables
$ var1='some text'
$ var2='var1'
$ echo ${!var2}
some text
$ var2='var1'
$ echo ${!var2}
some text
String and array manipulation
From tldp.org we have two articles covering similar things named Issue18 and string-manipulation:
Creating an array and indexing into arrays:
$ arr=(hi there dude)
$ echo "Middle value: ${arr[1]}"
$ echo "Middle value: ${arr[1]}"
Middle value: there
$ echo ${arr[*]}
hi there dude
$ echo ${arr[*]}
hi there dude
Indexing into strings: ${variable_name:start_position:length}
$ var="Hello" && echo ${var:1:3}
ell
Separate a path and its base filename.
$ FILE="/some/file/with/path.txt"$ basename $FILE
path.txt
$ dirname $FILE
/some/file/with
Another way to do this (the first doesn't always seem to work)
path.txt
I use this in scripts within a usage() function to print the name of the script
$ usage() { echo "Usage: ${0##*/} <options>" ... }
Subscribe to:
Posts (Atom)