Skip to content

Instantly share code, notes, and snippets.

@endemics
endemics / install_jinja2_unprivileged.sh
Created December 10, 2015 01:08
Install python stuff in an unprivileged way
#!/bin/bash
# requires curl and python 2.7 to be installed
curl -s -o get-pip.py -L https://bootstrap.pypa.io/get-pip.py && \
python get-pip.py --root $(pwd)/tmppython
PATH=$(pwd)/tmppython/usr/local/bin:$PATH \
PYTHONPATH=$(pwd)/tmppython/usr/local/lib/python2.7/dist-packages/:$PYTHONPATH \
pip install --root $(pwd)/tmppython virtualenv
@endemics
endemics / hard_soft_limits_chpst.diff
Created September 20, 2012 18:12
allowing hard and soft limit changes in chpst
--- src/chpst.c.orig 2009-10-04 22:44:02.000000000 +0200
+++ src/chpst.c 2012-09-20 20:53:01.000000000 +0200
@@ -168,7 +168,13 @@
struct rlimit r;
if (getrlimit(what, &r) == -1) fatal("unable to getrlimit()");
- if ((l < 0) || (l > r.rlim_max))
+ if (l > r.rlim_max) {
+ if (geteuid() == 0)
+ r.rlim_cur =r.rlim_max =l;
@endemics
endemics / authkeys-report
Created March 8, 2012 13:58
authkeys-report - create a table with ssh keys type/strength/finger print from authorized_keys. no known licence, copied from http://unix.stackexchange.com/questions/2116/given-keys-in-ssh-authorized-keys-format-can-you-determine-key-strength-easi
#!/bin/sh
# usage: authkeys-report <authorized_keys-file>
set -ue
tmp="$(mktemp -t fingerprint-authkeys.XXXXXXXX)"
trap 'rm -f "$tmp"' 0
while read opts key; do
@endemics
endemics / getswap.sh
Created September 6, 2011 15:20
get swap usage for all running processes
#!/bin/bash
# Get current swap usage for all running processes
# based on http://northernmost.org/blog/find-out-what-is-using-your-swap/
# by Erik Ljungstrom 27/05/2011
SUM=0
OVERALL=0
for DIR in `find /proc/ -maxdepth 1 -type d | egrep "^/proc/[0-9]"` ; do
PID=`echo $DIR | cut -d / -f 3`
PROGNAME=`ps -p $PID -o comm --no-headers`
for SWAP in `grep Swap $DIR/smaps 2>/dev/null| awk '{ print $2 }'`
#!/bin/sh
# simple script to toggle on/off the camera of my eeepc 1000ha
camera=/sys/devices/platform/eeepc/camera
if [ `cat $camera` -eq 1 ]
then
echo -n "disabling the camera..."
echo 0 > $camera
lsusb |grep "UVC Webcam" 2>&1 >/dev/null
if [ $? -eq 1 ]
#!/bin/sh
# simple windows backup system
# I was fed up to continuously reinstall my mum's windows so I came up
# with this system.
# she has 3 partitions as follows:
# hda1- windows system partition (15GB)
# hda2- a swapless basic debian partition (20GB)
# hda3- windows data partition
#
# * windows is configured so the user data are on the windows data partition