Skip to content

Instantly share code, notes, and snippets.

View 4np's full-sized avatar

Jeroen Wesbeek 4np

  • ServiceNow
  • The Netherlands
View GitHub Profile
@4np
4np / unzip.sh
Last active January 16, 2023 15:10
Unzip multipart zip file on Mac OS X / Linux / Unix oneliner
cat *.zip > combined.zip;zip -FF combined.zip --out combined-fixed.zip;rm combined.zip;yes A|unzip -qq combined-fixed.zip;rm combined-fixed.zip
@4np
4np / github.sh
Last active October 12, 2015 20:18
List your personal top 5 GitHub new items
# Commands to retrieve the top 5 personal news items from GitHub. Can easily be used with GeekTools:
# top 5 news items
GITHUB_USER="...";GITHUB_TOKEN="...";curl --silent "https://github.com/$GITHUB_USER.private.atom?token=$GITHUB_TOKEN"|grep -E '(title type="html">|published>)'|sed -e 's/<title type="html">//' -e 's/<\/title>//' -e 's/<published>//' -e 's/<\/published>/ DATE /' -e 's/ //' -e 's/\([0-9]*\)-\([0-9]*\)-\([0-9]*\)/\3-\2/' -e 's/T\([0-9]*\):\([0-9]*\):\([0-9]*\)Z/ \1:\2/'|awk 'gsub(/DATE $/,""){printf $0;next;}1'|head -n 5
# same as above but now separated into three commands for formatting purposes:
# 1. top 5 news date times:
GITHUB_USER="...";GITHUB_TOKEN="...";curl --silent "https://github.com/$GITHUB_USER.private.atom?token=$GITHUB_TOKEN"|grep -E '(published>)'|sed -e 's/<published>//' -e 's/<\/published>//' -e 's/\([0-9]*\)-\([0-9]*\)-\([0-9]*\)/\3-\2/' -e 's/T\([0-9]*\):\([0-9]*\):\([0-9]*\)Z/ \1:\2/'|head -n 5
# 2. top 5 new users:
GITHUB_USER="...";GITHUB_TOKEN="...";curl --silent "
@4np
4np / oldports.sh
Last active October 13, 2015 16:38
Bash alias to list and install older versions of ports in macports
# alias for bash to install older ports in macports
# (several port versions can live next to each other)
# add this code to your ~/.profile to have the
# oldports command / alias available in terminal.
#
# Usage: oldport portname
# oldport portname version
#
# author Jeroen Wesbeek <work@osx.eu>
oldport() {
@4np
4np / dbnp.org_studies.conf
Last active December 11, 2015 15:29
Apache virtual host containing a load balanced proxy configuration to GSCF running on Apache Tomcat 7.x
<VirtualHost *:80>
ServerName studies.dbnp.org
ServerAlias gscf.dbnp.org
ErrorLog /var/log/apache2/dbnp.org_gscf-studies-error.log
CustomLog /var/log/apache2/dbnp.org_gscf-studies-access.log combined
# disable gzip encoding for monitoring page
<Location /monitoring>
RequestHeader unset Accept-Encoding
@4np
4np / portsums.sh
Created January 24, 2013 13:20
Generate the md5, sha and RMD160 sums for a particular file. Very useful for create new Portfiles for Macports as a portfile validates these particular checksums for downloaded files. Usage: portsums /path/to/file.tgz
# hash methods
rmd160() {
openssl dgst -rmd160 $1
}
portsums() {
echo 'MD5 : '`md5 $1`
echo 'SHA : '`shasum $1`
echo 'RMD160 : '`rmd160 $1`
}
@4np
4np / generateGraphVideo.sh
Last active December 11, 2015 15:38
Generate a graph video of a svn project. Requires gource and ffmpeg
# alias for creating a graph video of a git project
g() {
DEFAULT_USER_IMAGE=~/Pictures/avatars/default.png
USER_IMAGE_DIR=~/Pictures/avatars
BRANCH=master
# determine first commit for this branch
FIRST_COMMIT=`git log $BRANCH --reverse --format=%H|head -n 1`
# get the third last commit to have a pretty accurate timestamp
LAST_COMMIT=`git log $BRANCH --format=%H|head -n 3|tail -n 1`
@4np
4np / stopStartMongoDB.sh
Created January 24, 2013 13:54
two aliasses (mongostart and mongostop) to stop and start a mongoDB NOSQL store, installed using MacPorts
# mongo db
# see http://noteit.jiaeil.com/install-mongodb-via-macports-on-mac
alias mongostart="sudo nice mongod --rest -f /opt/local/etc/mongodb/mongod.conf; clear; tail -f /opt/local/var/log/mongodb/mongodb.log"
mongostop_func () {
# local mongopid=`ps -o pid,command -ax | grep mongod | awk '!/awk/ && !/grep/{print $1}'`;
# just find a simpler way
local mongopid=`less /opt/local/var/db/mongodb_data/mongod.lock`;
if [[ $mongopid =~ [[:digit:]] ]]; then
sudo kill -15 $mongopid;
echo mongod process $mongopid terminated;
@4np
4np / connected.sh
Created January 24, 2013 13:55
show users / ips connected to your computer
# show connected users / ip's
alias connected="netstat -f inet -n | awk '/\.548 / { print $5 }' | sed 's/\.[^.]*$//'"
@4np
4np / prompt.sh
Last active August 4, 2018 10:42
my favorite prompt
# change prompt
LOGIN_NAME=$(whoami)
if [[ ${EUID} == 0 ]] ; then
if [ ${#LOGIN_NAME} -gt 20 ]; then
PS1='\[\033[01;35m\]${SCREENTITLE}\[\033[01;34m\]\w \$\[\033[00m\] '
else
PS1='\[\033[01;36m\]${SCREENTITLE}\[\033[01;31m\]\h\[\033[01;34m\] \W \$\[\033[00m\] '
fi
else
if [ ${#LOGIN_NAME} -gt 20 ]; then
@4np
4np / .gitignore
Created January 29, 2013 13:45 — forked from adamgit/.gitignore
#########################
# .gitignore file for Xcode4 / OS X Source projects
#
# NB: if you are storing "built" products, this WILL NOT WORK,
# and you should use a different .gitignore (or none at all)
# This file is for SOURCE projects, where there are many extra
# files that we want to exclude
#
# For updates, see: http://stackoverflow.com/questions/49478/git-ignore-file-for-xcode-projects
#########################