Skip to content

Instantly share code, notes, and snippets.

View roberto-filho's full-sized avatar

Roberto Welzel Filho roberto-filho

View GitHub Profile
@deviantony
deviantony / install-latest-compose.sh
Last active July 22, 2024 11:41
Install latest version of Docker Compose
#!/bin/bash
## THIS IS THE OLD WAY
## Nowadays, simply follow the Compose installation instructions in the official documentation:
## https://docs.docker.com/compose/install/
# get latest docker compose released tag
COMPOSE_VERSION=$(curl -s https://api.github.com/repos/docker/compose/releases/latest | grep 'tag_name' | cut -d\" -f4)
@JeffBelback
JeffBelback / docker-destroy-all.sh
Last active May 25, 2024 20:19
Destroy all Docker Containers and Images
#!/bin/bash
# Stop all containers
containers=`docker ps -a -q`
if [ -n "$containers" ] ; then
docker stop $containers
fi
# Delete all containers
containers=`docker ps -a -q`
if [ -n "$containers" ]; then
docker rm -f -v $containers
@giosakti
giosakti / Application.java
Last active March 15, 2019 01:38
gradle-jersey-jetty-sample
package com.starqle.hcm;
import com.sun.jersey.spi.container.servlet.ServletContainer;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.servlet.ServletContextHandler;
import org.eclipse.jetty.servlet.ServletHolder;
public class Application {
public static void main (String[] args) throws Exception {
ServletHolder sh = new ServletHolder(ServletContainer.class);
@caarlos0
caarlos0 / eq.or.higher.than.9.2.sql
Created June 3, 2014 19:25
PostgreSQL query monitoring (deadlocks and shit)
SELECT bl.pid AS blocked_pid,
a.usename AS blocked_user,
ka.query AS blocking_statement,
now() - ka.query_start AS blocking_duration,
kl.pid AS blocking_pid,
ka.usename AS blocking_user,
a.query AS blocked_statement,
now() - a.query_start AS blocked_duration
FROM pg_catalog.pg_locks bl
JOIN pg_catalog.pg_stat_activity a ON a.pid = bl.pid
@roberto-filho
roberto-filho / drop-users.sql
Created March 25, 2014 12:31
Query para dropar todos os usuários de uma base especificada pela query
SELECT pg_terminate_backend(pg_stat_activity.procpid)
FROM pg_stat_activity
WHERE pg_stat_activity.datname = 'gruberdev'
AND procpid <> pg_backend_pid();
@lttlrck
lttlrck / gist:9628955
Created March 18, 2014 20:34
rename git branch locally and remotely
git branch -m old_branch new_branch # Rename branch locally
git push origin :old_branch # Delete the old branch
git push --set-upstream origin new_branch # Push the new branch, set local branch to track the new remote
@fappel
fappel / DisplayHelper.java
Last active January 4, 2017 05:32
JUnit 4 TestRule to ease SWT Display Tests (Dependencies: JUnit, SWT, Guava)
import static com.google.common.collect.Iterables.toArray;
import static com.google.common.collect.Lists.newLinkedList;
import static java.util.Arrays.asList;
import java.util.Collection;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.junit.rules.TestRule;
@aldrinleal
aldrinleal / Sample POM
Created February 25, 2014 11:04
Bootstrap pom for JBake Stuff
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>br.com.tasafo</groupId>
<artifactId>yoursite</artifactId>
<packaging>pom</packaging>
<version>1.0-SNAPSHOT</version>
<properties>
<hostname>yoursite.com</hostname>
@roberto-filho
roberto-filho / server.sh
Last active December 26, 2015 05:09 — forked from luizkowalski/server
sudo ip addr add 192.168.0.183/24 dev eth0 #Configura o ip
ip route add default via 192.168.0.106 #Configura o proxy
sudo ip link set dev eth0 up #Sobe a interface
# Verificar o arquivo /etc/resolv.conf, deve conter as seguintes linhas
nameserver 8.8.8.8
nameserver 8.8.4.4
#Subir o postgres
su - postgres #Loga como superuser postgres
@antonio
antonio / delete_rebased_and_merged_branches.sh
Created January 21, 2013 14:58
Delete branches that were rebased (reference never updated) and merged into master
#!/bin/sh
for branch in $(git branch -a | sed 's/^\s*//' | sed 's/^remotes\///' | grep -v 'master$'); do
last_commit_msg="$(git log --oneline --format=%f -1 $branch)"
if [[ "$(git log --oneline --format=%f | grep $last_commit_msg | wc -l)" -eq 1 ]]; then
if [[ "$branch" =~ "origin/" ]]; then
local_branch_name=$(echo "$branch" | sed 's/^origin\///')
if [[ -n "$EXEC" ]]; then
git push origin :$local_branch_name
else