sh 从http://vimcasts.org获取vimcasts

从http://vimcasts.org获取vimcasts

get-vimcasts.sh
#!/bin/sh

curl -f http://media.vimcasts.org/videos/index.json | grep m4v | awk {'print $2'} | sed 's/\"//g' | sed 's/,//g' | sort -t '/' -k5,5g

sh eclipse可执行文件

eclipse可执行文件

eclipse.sh
#!/bin/sh
# name it eclipse
# put it in /usr/bin
# chmod 755 /usr/bin/eclipse

export ECLIPSE_HOME="/opt/eclipse/latest"
$ECLIPSE_HOME/eclipse $*

sh 如何在linux上安装eclipse

如何在linux上安装eclipse

install-eclipse.sh
su -

# create eclipse location
mkdir /opt/eclipse

# Unzip it
tar -xvzf /path/.../eclipse-java-luna-SR2-linux-gtk.tar.gz -C /opt/eclipse

# create link
ln -s /opt/eclipse/eclipse/ /opt/eclipse/latest

# Permissions
hmod -R +r /opt/eclipse/

sh 登录时设置JDK Home的文件

登录时设置JDK Home的文件

jdk_home.sh
# Put this file under /etc/profile.d

export JAVA_HOME=/usr/java/latest
export PATH=$PATH:JAVA_HOME/bin

sh 安装JDK

安装JDK

install-jdk.sh
# root
su -

# Install JDK in system
rpm -Uvh /path/.../jdk-8u40-linux-i586.rpm

# Use correct Java
alternatives --install /usr/bin/java java /usr/java/latest/jre/bin/java 2000000
alternatives --install /usr/bin/javac javac /usr/java/latest/bin/javac 2000000
alternatives --install /usr/bin/javaws javaws /usr/java/latest/jre/bin/javaws 2000000
alternatives --install /usr/bin/jar jar /usr/java/latest/bin/jar 2000000

# Example how to swap javac
# alternatives --config javac


sh 安装IntelliJ

安装IntelliJ

idea-install.sh
# root
su -

# Create IntelliJ location
mkdir -p /opt/idea

# Untar installation
tar -xvzf /path/.../ideaIC-14.1.tar.gz -C /opt/idea

# Create link for latest IntelliJ
ln -s /opt/idea/idea-IC-141.177.4/ /opt/idea/latest

chmod -R +r /opt/idea

sh centos-install-syntax-highlighting-in-less.sh

macports-install-syntax-highlighting-in-less.sh
# Enable syntax-highlighting in less.
#
# First, add these two lines to ~/.bashrc
#     export LESSOPEN="| /opt/local/bin/src-hilite-lesspipe.sh %s"
#     export LESS=" -R "

sudo port install source-highlight
centos-install-syntax-highlighting-in-less.sh
# Enable syntax-highlighting in less.
# Last tested on CentOS 6.3.
#
# First, add these two lines to ~/.bashrc
#     export LESSOPEN="| /usr/bin/src-hilite-lesspipe.sh %s"
#     export LESS=" -R "

sudo yum -y install boost boost-devel ctags

wget http://springdale.math.ias.edu/data/puias/unsupported/6/x86_64/source-highlight-3.1.6-3.puias6.x86_64.rpm
source-highlight-3.1.6-3.puias6.x86_64.rpm
sudo yum -y install source-highlight

sh 来自:<br/> https://discussions.apple.com/thread/3227951?start=0&tstart=0 <br/> <br/>此脚本单独转储postgres中的所有数据库。 <br/>数据库

来自:<br/> https://discussions.apple.com/thread/3227951?start=0&tstart=0 <br/> <br/>此脚本单独转储postgres中的所有数据库。 <br/>数据库被抽真空然后被转储。 <br/>转储格式当前设置为压缩pgsql转储(请参阅$ BACKUP_OPTIONS中的“-F c”)<br/>文件名包含“databasename” - “backupdade”.pgdump <br/>我编程为自动清除超过两周的备份(请参阅$ EXP_DATE中的“-2w”)<br/>如果删除数据库,则必须手动删除该数据库的备份。 <br/> <br/>通过将可执行脚本放在somwhere并将其添加到root的crontab中,我已启用此脚本的每日运行:sudo crontab -e <br/>输入以下行,每天开始备份在6点。根据您自己的设置调整路径和脚本名称。 <br/> <br/> 0 6 * * *〜/ .bin / postgres_dump.sh> / dev / null 2>&1

postgres_backup.sh
# #!/bin/bash
if (test "`whoami`" != "root") then
        echo "You need to be root to start this"
        exit 1
fi
 
 
PG_PORT="5432"
PG_USER="_postgres"
PG_BIN="/usr/bin/"
 
 
ACT_DATE=$(date '+%y-%m-%d')
EXP_DATE=$(date -v -2w '+%y-%m-%d')
BACKUP_DIR="/Backups/postgres"
LOGFILE=$BACKUP_DIR"/_pg_backup.log"
COMPRESSION="9"
PG_CON="-U $PG_USER"
BACKUP_OPTIONS="$PG_CON -b -C -F c -Z $COMPRESSION"
VACUUM_OPTIONS="$PG_CON -eq"
 
 
echo "***** DB_BACKUP $ACT_DATE *****" >>$LOGFILE
for db in `$PG_BIN/psql $PG_CON -lt | sed /\eof/p | grep -v = | awk {'print $1'}`
  do
    # vacuum
    if [ "X" == "X$db" ]; then
          continue;
    fi
    echo $(date '+%c')" -- vacuuming database $db" >> $LOGFILE
    if $PG_BIN/vacuumdb $VACUUM_OPTIONS $db
      then
      #echo "OK!" >>$LOGFILE
          sleep 1
    else
      echo "No Vacuum in database $db!" >>$LOGFILE
    fi
    # backup
    echo $(date '+%c')" -- backing up database $db" >>$LOGFILE
    if  $PG_BIN/pg_dump $BACKUP_OPTIONS -f $BACKUP_DIR/$db-$ACT_DATE.pgdump $db
      then
      if [ -e $BACKUP_DIR/$db-$EXP_DATE.pgdump ]; then
          echo $(date '+%c')" -- deleting old backup" >>$LOGFILE
          rm $BACKUP_DIR/$db-$EXP_DATE.pgdump
      fi
    else
      echo "FAIL Database $db backup!" >>$LOGFILE
    fi
  done

sh 使用漂亮的格式和组合,将git日志中的大部分有用信息编译成按时间顺序排列的JSON数组

使用漂亮的格式和shell命令的组合,将git日志中的大多数有用信息编译成按时间顺序排列的JSON数组。

git-log2json.sh
# Requires GNU's implementation of sed, which is provided by default on Linux. 
# If you are on a Mac try installing gnu-sed using Homebrew and replace
# all instances of `sed` with `gsed` in the script.

# Sets the date format to iso8601. Change it if you need to.

# Note that several fields may contain invalid JSON strings and the script 
# does not check for that. You may wan to run the output through a linter
# in order to make sure the output is usable.

# Git log reference: http://git-scm.com/docs/git-log

git --no-pager log --all --no-merges --ignore-missing --shortstat --date=iso --pretty=format:\
'{ "commit_hash": "%H", "tree_hash": "%T", "parent_hash": "%P", "author": { "name": "%an", "mailmap_name": "%aN", "email": "%ae", "mailmap_email": "%aE", "date": "%ad" }, "committer": { "name": "%cn", "mailmap_name": "%cN", "email": "%ce", "mailmap_email": "%cE", "date": "%cd" }, "subject": "%s", "ref_name": "%d", "notes": "%N",' |\
sed -r -e 's/^ ([0-9]*) files? changed(, ([0-9]*) insertions?\(\+\))?(, ([0-9]*) deletions?\(-\))?/"files_changed": "\1", "insertions": "\3", "deletions": "\5" }/' -e '1i ]\n\n' | \
paste -d " " - - - | \
tail -r | \
tr "\n" , | \
sed -r -e '1i [' -e 's/ ,\]  ,$/\n]\n/' -e 's/\}\s*,\s*\{/},\n{/g'

sh 使用漂亮的格式和组合将git日志中的大多数有用信息编译成按时间顺序排列的制表符分隔列表

使用漂亮的格式和shell命令的组合,将git日志中的大多数有用信息编译成按时间顺序排列的制表符分隔列表。

git-log2tsv.sh
# Requires GNU's implementation of sed, which is provided by default on Linux. 
# If you are on a Mac try installing gnu-sed using Homebrew and replace
# all instances of `sed` with `gsed` in the script.

# Sets the date format to iso8601. Change it if you need to.

# Note that several fields may contain invalid characters and the script 
# does not check for that. You may have to use an encoding detector to 
# impose the right encoding on the concerned fields.

# Git log reference: http://git-scm.com/docs/git-log

git --no-pager log --all --no-merges --ignore-missing --shortstat --date=iso --pretty=format:\
'"%H"%x09"%T"%x09"%P"%x09"%an"%x09"%aN"%x09"%ae"%x09"%aE"%x09"%ad"%x09"%cn"%x09"%cN"%x09"%ce"%x09"%cE"%x09"%cd"%x09"%s"%x09"%d"%x09"%N"' | \
sed -r 's/^ ([0-9]*) files? changed(, ([0-9]*) insertions?\(\+\))?(, ([0-9]*) deletions?\(-\))?/"\1"\t"\3"\t"\5"/' | \
cat <<(echo '\n"commit_hash"\t"tree_hash"\t"parent_hash"\t"author_name"\t"author_mailmap_name"\t"author_email"\t"author_mailmap_email"\t"author_date"\t"committer_name"\t"committer_mailmap_name"\t"committer_email"\t"committer_mailmap_email"\t"committer_date"\t"subject"\t"ref_name"\t"notes"\t"files_changed"\t"insertions"\t"deletions"') | \
paste -d "\t" - - - | \
tail -r