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 / tomcat manager deploy
Last active October 12, 2022 19:13
tomcat - deploy war files using curl
# deploy under "path" context path
curl --upload-file appplication-0.1-1.war "http://tomcat:tomcat@localhost:8080/manager/deploy?path=/application-0.1-1
# undeploy
curl "http://tomcat:tomcat@localhost:8080/manager/undeploy?path=/application-0.1-1"
# ! tomcat7 uses /manager/text/undeploy and /manager/text/deploy paths
# tomcat6-admin (debian) or tomcat6-admin-webapps (rhel) has to be installed
# tomcat-users.xml has to be setup with user that has admin, manager and manager-script roles
@pete911
pete911 / rest response codes
Created January 10, 2013 17:34
diagram of rest response codes
http://i.stack.imgur.com/whhD1.png
@pete911
pete911 / gist:6219918
Last active December 31, 2020 00:39
jenkins with private github projects
- login to jenkins box (ssh)
- switch user to jenkins "sudo su -s /bin/bash jenkins"
- go to jenkins home directory "cd ~"
- generate keys (you need separate pair per github private project as the projects are on the same domain)
- "ssh-keygen -t rsa -f ~/.ssh/id_rsa_<project>" (replace <project> with your project name)
- repeat this for every github project
- crate "config" file in .ssh dir - "vim ~/.ssh/config" with the following content:
# <project1>
Host github.com-<project1>
HostName github.com
@pete911
pete911 / input stream to string
Created February 9, 2012 10:27
java - input stream to string (one liner)
return new Scanner(is).useDelimiter("\\A").next();
@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('/')
`sudo nmap -sP 192.168.1.0/24 | awk '/^Nmap/{ip=$NF}/B8:27:EB/{print ip}'` update `192.168.1.*` accordingly
@pete911
pete911 / tomcat monitoring
Last active April 8, 2017 13:59
monitoring tomcat
https://wiki.internet2.edu/confluence/display/CPD/Monitoring+Tomcat+with+JMX
-Dcom.sun.management.jmxremote
-Dcom.sun.management.jmxremote.port=8999
-Dcom.sun.management.jmxremote.ssl=false
-Dcom.sun.management.jmxremote.authenticate=false
-Djava.rmi.server.hostname=localhost
@pete911
pete911 / knife-ec2
Last active January 4, 2016 19:09
chef - knife-ec2 setup
--- install rvm ---
# get and execute rvm and source it
curl -sSL https://get.rvm.io | bash -s stable
source .rvm/scripts/rvm
# install ruby 2.1.0 and use it
rvm install ruby-2.1.0
rvm use 2.1.0
@pete911
pete911 / Spring Resources
Last active January 3, 2016 23:59
Java - get resources from classpath
import org.springframework.core.io.Resource;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
...
PathMatchingResourcePatternResolver resourceResolver = new PathMatchingResourcePatternResolver();
Resource[] resources = resourceResolver.getResources("conf/**/*.properties");
Resource resource = resources[0];
@pete911
pete911 / gist:6411270
Created September 2, 2013 10:04
key based authentication
ssh-keygen -t rsa
ssh-copy-id -i .ssh/id_rsa.pub username:password@remotehost