Skip to content

Instantly share code, notes, and snippets.

@gerjantd
gerjantd / gist:3827264
Created October 3, 2012 14:39
Shell: replace 'foo' with 'bar' in every java and xml file in folder tree
for f in `find . -type f -regextype awk -regex ".*/*.(xml|java)"`; do sed -i -e "s/foo/bar/g" $f; done
@gerjantd
gerjantd / get-mygists.sh
Created July 20, 2012 09:23
Github: API v3 call for retrieving my public gists
#!/bin/bash
mkdir mygists
cd mygists
curl -u "gerjantd" https://api.github.com/gists | json_xs > mygists.json
cat mygists.json | grep "\"id\"" | awk -F "\"" '{print $4}' > repos
for g in `cat repos`; do git clone [email protected]:$g.git gist-$g; done
@gerjantd
gerjantd / list_manually_installed_packages.py
Created July 20, 2012 08:59
Python, Debian, Ubuntu: list manually installed packages
"""List manually installed debian packages
Use as root or with sudo:
python list_manually_installed_packages.py [date]
output results to /var/log/manually_installed_software_<hostname>.csv
Optional argument [date] will list only packages installed since that date.
The date format is YYYYMMDD and be used e.g. as
@gerjantd
gerjantd / gist:3121258
Created July 16, 2012 07:03
Python: simple http server, localhost only
import sys
import BaseHTTPServer
from SimpleHTTPServer import SimpleHTTPRequestHandler
HandlerClass = SimpleHTTPRequestHandler
ServerClass = BaseHTTPServer.HTTPServer
Protocol = "HTTP/1.0"
if sys.argv[1:]:
port = int(sys.argv[1])
@gerjantd
gerjantd / gist:2984296
Created June 24, 2012 18:20
Linux system info summary and simple way to prevent remote from closing connection
watch -n 8 "cat /etc/issue | grep '[a-z]'; uname -a; top -b -n 1 | head -1; who"
@gerjantd
gerjantd / gist:2627213
Created May 7, 2012 10:50
Maven: dynamically build classpath containing all maven dependencies
Download
--------
svn co https://src.springframework.org/svn/spring-samples/task-basic/trunk
(http://blog.springsource.org/2010/01/05/task-scheduling-simplifications-in-spring-3-0/)
Build
-----
mvn clean package
@gerjantd
gerjantd / gist:2498743
Created April 26, 2012 10:49
Git: split a previous commit
If you accidentally combine multiple changes into one commit, here's how to split it. You will need this if you wish to merge the changes seperately; cherry-pick operates on commits.
admin@STAMMETJEVM ~/My Documents/git/gerjantd
$ git clone https://[email protected]/gerjantd/foo.git
Cloning into 'foo'...
remote: Counting objects: 301, done.
remote: Compressing objects: 100% (178/178), done.
remote: Total 301 (delta 59), reused 301 (delta 59)
Receiving objects: 100% (301/301), 152.94 KiB, done.
Resolving deltas: 100% (59/59), done.
@gerjantd
gerjantd / gist:2497278
Created April 26, 2012 07:44
Eclipse regexp: search and replace
To change this
vraag1.info
vraag2.info
vraag3a.info
vraag3b.info
into this
question.info.1
@gerjantd
gerjantd / gist:2465765
Created April 22, 2012 18:02
Github: API v1 call for retrieving my public gists (obsolete)
wget -O `date +%Y%m%d`-gerjantd-public-gists.json http://gist.github.com/api/v1/json/gists/gerjantd
Format the downloaded json:
sudo apt-get install libjson-perl
sudo apt-get install curl
curl http://gist.github.com/api/v1/json/gists/gerjantd | json_xs
Automate cloning of all gists:
@gerjantd
gerjantd / dwr20.dtd
Created April 22, 2012 17:44
DWR DTDs to cache in Eclipse XML Catalog User Specified Entries
<?xml version="1.0" encoding="UTF-8"?>
<!-- This is the DTD for DWR v2.x -->
<!--
Top level conviguration element.
-->
<!ELEMENT dwr (
(init?), (allow?), (signatures?)
)>