Skip to content

Instantly share code, notes, and snippets.

View pete911's full-sized avatar
🏠
Working from home

Peter Reisinger pete911

🏠
Working from home
View GitHub Profile
@pete911
pete911 / grails with git
Created February 14, 2012 13:01
grails with git
grails integrate-with --git
@pete911
pete911 / vim highlight tabs
Created March 7, 2012 21:16
vim highlight tabs
:set listchars=tab:>-,trail:-
@pete911
pete911 / curl - reponse code
Created March 22, 2012 15:38
get http response code
# -s = silent, -w = write out format, -o = output file
curl -s -w %{http_code} http://www.google.co.uk/ -o /dev/nul
@pete911
pete911 / python simple http server
Created March 22, 2012 17:40
basic python http server
import BaseHTTPServer
class Handler(BaseHTTPServer.BaseHTTPRequestHandler):
mappings = {'/' : {'GET' : 'test'}}
def main_handler(self, method='GET'):
# get request url (without url params) and remove trailing /
request_url = self.path.split('?')[0].rstrip('/')
@pete911
pete911 / gist:2299764
Created April 4, 2012 08:47
change underscores for hyphens in file names
for i in *.txt; do mv $i $(echo "$i" | sed 's/_/-/'); done
@pete911
pete911 / line count
Last active October 4, 2015 05:18
count lines in a file
# sed
sed -n '$=' file
# awk
wc -l file | awk '{print $1}'
@pete911
pete911 / file to array
Created August 15, 2012 09:05
convert file to array
String fileContent = new Scanner(file).useDelimiter("\\A").next();
String[] fileLines = fileContent.split(System.lineSeparator());
@pete911
pete911 / set time to 0 in date
Created August 15, 2012 12:07
returns date object with time set to 0
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
calendar.set(Calendar.HOUR_OF_DAY, 0);
calendar.set(Calendar.MINUTE, 0);
calendar.set(Calendar.SECOND, 0);
calendar.set(Calendar.MILLISECOND, 0);
return calendar.getTime();
@pete911
pete911 / delete recursively
Created November 30, 2012 13:44
delete .svn directories recursively
find . -type d -name .svn | xargs rm -rf
@pete911
pete911 / sed - search and replace
Created December 2, 2012 20:31
search and replace
find src/main/java/ -type f -exec sed -i 's/SimpleJdbcTemplate/NamedParameterJdbcTemplate/g' {} \;