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
| # drops first portion of a path $1 if length is greater than $2 | |
| function __droppath { | |
| if [[ ${#1} -gt $2 ]]; then | |
| p=$1 | |
| while [ ${#p} -gt $2 ]; do | |
| p="/"$(echo "$p"|cut -d"/" -f3-) | |
| done | |
| echo "..."$p | |
| else | |
| echo $1 |
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
| def fib(n): | |
| if n <= 2: | |
| return 1 | |
| else: | |
| return fib(n-1) + fib(n-2) |
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
| echo 'task goes here' | cat - todo.txt > temp && mv temp todo.txt | |
| # OR | |
| cat <(echo "task goes here") todo.txt > todo_new.txt | |
| # OR | |
| echo -e "task goes here\n$(cat todo.txt)" > todo.txt | |
| # OR | |
| sed -i '1s/^/task goes here\n/' todo.txt | |
| # OR | |
| sed -i '1itask goes here' todo.txt |
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
| # 1. download and install PostgreSQL 9.3 (remember the password your entered) | |
| # 2. install PostGIS using Stackbuilder (it's a part of PostgreSQL 9.3 installation) | |
| # Make sure postgeres is started | |
| # Run script that fix issues with choice_web: | |
| psql -U postgres -d postgres -f choice_web_migr.sql | |
| # Load the dump (that might take upto 10min): | |
| psql -U postgres -f choice_web_02_21_2014.dump -d choice_web 2>choice_web_log.err |
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
| # Collect data until ^C: | |
| while true ; do df /data ; sleep 1 ; done | tee storage.txt | |
| # Extract "Used field": | |
| grep /dev/md0 storage.txt | sed 's/ */\t/g' | cut -f4 | |
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
| # on the source (appbuild-vm4): | |
| nc -l 7879 < /data/Traces/telstra_nexus.erf | |
| # on the target | |
| nc appbuild-vm4 7879 > /data/telstra_nexus.erf | |
| ## I have tried with compression, but with fast network it performed poorer (in my case with 11GB file 15 min vs. 1.5 min): |
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
| grep -E "\\\$1 = '[0-9]+', \\\$2 = '[0-9]+', \\\$3 = '[0-9]+', \\\$4 = '[0-9]+'" /endace/pgsql/pg_log/postgresql-24.log | sed -n "s/.*'\([0-9]*\)'.*'\([0-9]*\)'.*'\([0-9]*\)'.*'\([0-9]*\)'.*/\1,\2,\3,\4/p" | |
| grep -E "\\\$1 = '[0-9]+', \\\$2 = '[0-9]+', \\\$3 = '[0-9]+', \\\$4 = NULL, \\\$5 = NULL, \\\$6 = NULL, \\\$7 = 'byte'" /endace/pgsql/pg_log/postgresql-24.log | sed -n "s/.*'\([0-9]*\)'.*'\([0-9]*\)'.*'\([0-9]*\)'.*'\([0-9]*\)'.*/\1,\2,\3,\4/p" | |
| grep -E "\\\$1 = '[0-9]+', \\\$2 = '[0-9]+', \\\$3 = '[0-9]+', \\\$4 = NULL, \\\$5 = NULL, \\\$6 = NULL, \\\$7 = 'byte'" /endace/pgsql/pg_log/postgresql-24.log | sed -n "s/.*'\([0-9]*\)'.*'\([0-9]*\)'.*'\([0-9]*\)'.*'\([0-9]*\)'.*/\1,\2,\3,\4/p" | awk -F, '{print $1,$2,$3,$4, $2-$1}' |
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
| while true ; do echo -n $RANDOM$RANDOM$RANDOM$RANDOM$RANDOM$RANDOM$RANDOM$RANDOM$RANDOM$RANDOM$RANDOM$RANDOM$RANDOM$RANDOM$RANDOM$RANDOM$RANDOM$RANDOM$RANDOM$RANDOM$RANDOM$RANDOM$RANDOM$RANDOM | tr "0" "*" ; sleep "0.$RANDOM" ; echo $RANDOM$RANDOM$RANDOM ; sleep "0.$RANDOM" ;done |
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
| # $SD - script installation directory (e.g. /opt/tms/lib/dbmgr | |
| # for packages it can be arbitrary location) | |
| [ -z "$SD" -o ! -e "$SD" ] && SD="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" |
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
| /* Example of embedding Python in another program */ | |
| // to compile run: | |
| // gcc -o test $(python-config --cflags) test.c $(python-config --ldflags) && ./test | |
| #include<stdio.h> | |
| #include "Python.h" | |
| void initxyzzy(void); /* Forward */ | |
| main(int argc, char **argv) |