Skip to content

Instantly share code, notes, and snippets.

@cybic
cybic / watchforless.sh
Created September 18, 2012 12:35
Watch for changes in less files
#!/bin/bash
lesscommand="lessc"
inotifywait -qrm $1 |
while read line
do
#echo Plain {$line}
@cybic
cybic / Update remote
Created May 14, 2013 08:39
Kjør i git-repo for å oppdatere fra git.api.no til github
git remote set-url origin $(git remote show origin -n | grep "Fetch" | sed 's/.*\//git@github.com:amedia\//')
#!/bin/bash
TEMP=josm-tested-`date +%F`.jar
echo "Fetching josm"
wget "http://josm.openstreetmap.de/josm-tested.jar" -O $TEMP
REV=$(unzip -p $TEMP REVISION | grep Revision | sed 's/[^0-9]//g');
@cybic
cybic / tmux-completion.bash
Last active January 26, 2017 18:25
Get tab-completion for the `tmux' command in bash.
# bash completion for tmux
# Written by Oystein Steimler <oystein@nyvri.net>
#
# $ sudo cp tmux-completion.bash /etc/bash_completion.d/tmux
# $ . /etc/bash_completion.d/tmux
#
_sessions() {
SESSIONS=`tmux ls -F#{session_name} | xargs echo`
}
#!/bin/bash
mvn clean; mvn --batch-mode -Darguments=-Dmaven.test.skip=true -DpreparationGoals="clean install" release:prepare; mvn -Darguments="-Dmaven.test.skip=true -Dmaven.javadoc.skip=true" -Dgoals=deploy release:perform
import sys
import BaseHTTPServer
from SimpleHTTPServer import SimpleHTTPRequestHandler
HandlerClass = SimpleHTTPRequestHandler
ServerClass = BaseHTTPServer.HTTPServer
Protocol = "HTTP/1.0"
if sys.argv[1:]:
aptitude::Keep-Unused-Pattern "^linux-image.*$ | ^linux-restricted-modules.*$ | ^linux-ubuntu-modules.*$";
aptitude::Get-Root-Command "sudo:/usr/bin/sudo";
Aptitude::UI::Styles {
Default {fg white; bg default; set bold;};
};
@cybic
cybic / Greek it!
Last active August 29, 2015 14:07
//Scramble text
[].forEach.call(document.querySelectorAll('h1, h2, h3, p'), function(el){ el.textContent = el.textContent.replace(/([a-z])/g, function(m){ return String.fromCharCode(m.charCodeAt() - 1) } ) });
// Remove images
[].forEach.call(document.querySelectorAll('img'), function(img){ img.setAttribute('src', 'data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7'); img.style.backgroundColor = '#aaa' });
@cybic
cybic / remux
Last active November 22, 2017 19:16
Connect to a server using AutoSSH and attach to or create a tmux session
#!/bin/bash
#
# AutoSSH to host and create or connect to tmux session
#
# Author: Oystein Steimler <oystein@nyvri.net>
if [[ -z "$1" || -z "$2" ]]
then
echo -e "Missing parameter.\n\nUsage:\n\tremux <host> <session> [ssh-opts]\n\nExample:\n\tremux user@host.example.com session -4\n";
exit 1
@cybic
cybic / gist:261b42ee742489a5fc4a
Created December 11, 2014 15:25
List installed dpkg-packages from a file backup
# To list selections from a file backup
$ dpkg --admindir=/path/to/backup/of/var/lib/dpkg/ --get-selections