Skip to content

Instantly share code, notes, and snippets.

@denitram
denitram / gist:2593514
Created May 4, 2012 09:15
Admin-scripts: get spa-types from public server
#!/bin/bash
SPA_DIR=/data/spa-types/
SPA_FILE=spatypes.txt
HEADER="type,profile"
SPA_URL=http://spaserver2.ridom.de/dynamic/spatypes.txt
SPA_LOG=wget.log
DATUM="`date +%y%m%d%H%M`"
HTTP_PROXY=http_proxy=http://wwwproxy-dmz.rivm.nl:8080/
export $HTTP_PROXY
@denitram
denitram / gist:2660202
Created May 11, 2012 14:44
Download a full website with wget –mirror
$ wget --mirror -p --convert-links -P ./LOCAL-DIR WEBSITE-URL
@denitram
denitram / backup_one.sh
Created June 1, 2012 12:54
Postgresql --- Backup one database
#!/bin/sh
PGBIN_DIR=/usr/bin/
PSQL="${PGBIN_DIR}/psql -w --username=postgres"
PG_DUMPALL="${PGBIN_DIR}/pg_dumpall --username=postgres"
PG_DUMP="${PGBIN_DIR}/pg_dump --username=postgres"
#
CRON_DIR=/home/postgres/cron
#DUMP_DIR=${HOME}/cron
#DUMP_DIR=/data/db/backups
DUMP_DIR=/data/postgres/backup
@denitram
denitram / postgreSQL-commands
Created June 1, 2012 12:56
Postgresql --- Restore a database
sudo -u postgres psql -U postgres < intspecinf_ont_schemas.dmp
sudo -u postgres psql -U postgres intspecinf_ont < intspecinf_ont_dataonly.dmp
# storybuilder example - dump from localhost & restore to remote server
* dump (incl. create tables)
/opt/postgresql/91/bin/pg_dump -h localhost -Udba_dubourgm --role=dba -Fp --no-tablespaces --no-owner --no-privileges storybuilder_tst > sb_20121128.dmp
* drop & recreate public schema
* restore
@denitram
denitram / gist:2853276
Last active June 16, 2018 06:55
vi -- handy tips
Copy lines 1-2 /paste after 3
:1,2t3
Move lines 4-5 /paste after 6
:4,5m6
Save lines to new file
:10,15w file
Delete blanke lines
@denitram
denitram / gist:2867547
Created June 4, 2012 09:55
Maven - handy commands
* export database using DbUnit
mvn dbunit:export -Pprofile -Ddest=sample-data.xml
@denitram
denitram / gist:3236083
Last active October 7, 2015 22:38
case translation
# plaatsen in profile
function trans
{
tr '[:upper:]' '[:lower:]' < $1 > $2
}
function TRANS
{
tr '[:lower:]' '[:upper:]' <$1 > $2
}
@denitram
denitram / find and xargs
Last active August 28, 2016 22:46
find & xargs
# Find tutorial;
# http://www.grymoire.com/Unix/Find.html
# find files modified less than 5 days ago
$ find . -type f -mtime -5 -print | xargs ls -l
# find files (with spaces in name) modified less than 5 days ago
$ find . -type f -mtime -5 -print0 | xargs -0 ls -l
# find & remove directories older than 200 days
@denitram
denitram / git
Last active November 5, 2018 20:59
Git
# source: http://www.vogella.com/articles/Git/article.html
# set proxy for git globally
$ git config --global http.proxy http://proxy:8080
# to check the proxy settings
$ git config --get http.proxy
# just in case you need to you can also revoke the proxy settings
$ git config --global --unset http.proxy
@denitram
denitram / regex
Last active August 28, 2016 22:47
8 Regular Expressions You Should Know
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