Skip to content

Instantly share code, notes, and snippets.

@Raffo
Raffo / Android.md
Last active December 4, 2017 03:58
Android
@Raffo
Raffo / Oracle.md
Last active May 11, 2018 19:44
Oracle

Oracle SQL distinct on single column

 select * 
 from TABLE_NAME 
 where rowid in 
  (
    select max(ROWID) 
    from TABLE_NAME 
    GROUP BY COLUMN_NAME
@Raffo
Raffo / Java.md
Last active August 29, 2015 14:19
Java

Java Print Method name //This is really dirty, but works, do not use this for production code, just for testing purposes.

public String getCurrentMethodName() {
	StackTraceElement stackTraceElements[] = (new Throwable()).getStackTrace();
	return stackTraceElements[1].toString();
}
@Raffo
Raffo / Docker.md
Last active December 21, 2017 09:40

ssh into a running docker container

sudo docker exec -i -t 665b4a1e17b6 bash #by ID

Removes all the exited containers.

docker rm $(docker ps -q -f status=exited)

Get logfile for a container:

@Raffo
Raffo / git.md
Last active April 29, 2019 08:14
Saving some common GIT patterns

Keep a branch in sync with master

git checkout master
git pull
git checkout branchname
git merge master

I made some changes on the master but I want to bring (and commit) them to a different (NEW) branch.

@Raffo
Raffo / ssh-scp.md
Last active October 14, 2015 16:17
Fun with ssh and scp

Fun with ssh and scp

Estabilish a shh tunnel

ssh -i private_key user@remote_host -L local_port:remote_host:remote_port -f -N

scp to remote host

scp file user@IP:/dir/to/write/to

SOCKS5 dirty trick

ssh -D127.0.0.1:1080 vagrant@localhost -p 2222

@Raffo
Raffo / clam.md
Last active October 5, 2015 18:55
Clamav
@Raffo
Raffo / tcpdump.md
Last active February 12, 2019 17:57
tcpdump
sudo tcpdump -i any -X -s 0 dst HOST_IP
sudo tcpdump -i any -X -s 0 src host localhost -w /tmp/outfile1
@Raffo
Raffo / aws_tips.md
Created February 16, 2016 20:57
Aws tips and tricls

For AWS generated keys

C:\> openssl pkcs8 -in path_to_private_key -inform PEM -outform DER -topk8 -nocrypt | openssl sha1 -c

For manually generated and imported keys

C:\> openssl rsa -in path_to_private_key -pubout -outform DER | openssl md5 -c
@Raffo
Raffo / resources.go
Created July 31, 2016 10:58
go-swagger gist
func (p *ProjectResponse) projectsOKResponse(projects []*models.Project, ginCtx *gin.Context) {
ginCtx.JSON(http.StatusOK, projects)
}
func (p *ProjectResponse) projectOKResponse(project *models.Project, ginCtx *gin.Context) {
ginCtx.JSON(http.StatusOK, project)
}
func (p *ProjectResponse) projectCreateOKResponse(ginCtx *gin.Context) {