This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#---To change the passphrase on your default rsa key: | |
$ ssh-keygen -p -f ~/.ssh/id_rsa | |
#---Keep alive | |
~/.ssh/config | |
Host * | |
ServerAliveInternal 30 | |
TCKeepAlive yes |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# List installed packages | |
# List all services | |
systemctl list-unit-files | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#--- Commandline history substitution | |
* Replace old by new in prevous command | |
^old^new | |
^old^new is equivalent to !!:s/old/new | |
* Replace globally | |
!!:gs/old/new | |
#--- Batch renaming file |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
* quick and dirty | |
for i in `ls` ; do mv "$i" "$(echo $i | tr A-Z a-z)"; done | |
* beter version | |
for i in $(find . -type f -name "*[A-Z]*"); do mv "$i" "$(echo $i | tr A-Z a-z)"; done | |
-name "*[A-Z]*" ensures that only files with capital letters are found. For example, if files with only lowercase letters are found and moved to the same file, mv will display the are the same file error. | |
Thanks to Steve see: http://stackoverflow.com/questions/13051871/change-filenames-to-lowercase-in-ubuntu-in-all-subdirectories |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Add the first line of file1 at the top of file2 | |
$ h=head -n 1 file2 | |
$ sed -i "1s/^/$h \n/" file2 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
java -cp ~/.m2/repository/org/hsqldb/hsqldb/2.2.8/hsqldb-2.2.8.jar org.hsqldb.util.DatabaseManager |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Set proxy settings in Ubuntu for eclipse, maven and apt | |
#### variables | |
ECLIPSE_SETTINGS_DIR="/home/martine/apps/springsource/sts-3.4.0.M1/configuration/.settings/" | |
ECLIPSE_SETTINGS_FILE="org.eclipse.core.net.prefs" | |
ECLIPSE_SETTINGS_PROXY="org.eclipse.core.net.prefs-PROXY" | |
ECLIPSE_SETTINGS_NOPROXY="org.eclipse.core.net.prefs-NOPROXY" | |
ECLIPSE_SETTINGS=$ECLIPSE_SETTINGS_DIR$ECLIPSE_SETTINGS_FILE |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# First, make a dump of the database without data (-s) | |
$ pg_dump -h localhost -U username -Fc -s -f db_dump dbName | |
# Create a list of the functions | |
$ pg_restore -l db_dump | grep FUNCTION > function_list | |
# Restore the functions in an other database | |
$ pg_restore -h localhost -U username -d other-dbName -L function_list db_dump |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Viewing current PostgreSQL queries | |
-- source: http://chrismiles.info/systemsadmin/databases/articles/viewing-current-postgresql-queries/ | |
SELECT datname,pid,query,query_start FROM pg_stat_activity ORDER BY query_start ASC; | |
-- top-like view of current queries, grouped by how many of the same query are running at that instant and the usernames belonging to each connection. | |
SELECT count(*) as cnt, usename, current_query FROM pg_stat_activity GROUP BY usename,current_query ORDER BY cnt DESC; | |
-- List databases creation dates | |
SELECT (pg_stat_file('base/'||oid ||'/PG_VERSION')).modification, datname FROM pg_database ORDER BY modification; | |
SELECT (pg_stat_file('base/'||oid ||'/PG_VERSION')).modification, datname FROM pg_database ORDER BY datname; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
http://net.tutsplus.com/tutorials/other/8-regular-expressions-you-should-know/ | |
# insert a new line with '<null\>' as content every 6th line between lines 100 and 2000 | |
100,2000s/\v(.*\n){6}/\0\<null\/\>\r/g | |
see http://stackoverflow.com/questions/10413906/how-to-add-a-line-after-every-few-lines-in-vim | |
# delete blank lines | |
:g/^$/d | |
# join all lines |
NewerOlder