Skip to content

Instantly share code, notes, and snippets.

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

Bruno Ferreira bmbferreira

🏠
Working from home
View GitHub Profile
@bmbferreira
bmbferreira / autochecks logs
Created August 16, 2022 17:14
autochecks runner logs
August 15th 2022, 12:34:42.046 time="2022-08-15T12:34:42.046421428Z" level=warning msg="grpc: addrConn.createTransport failed to connect to {unix:///var/run/docker/containerd/containerd.sock <nil> 0 <nil>}. Err :connection error: desc = \"transport: Error while dialing dial unix:///var/run/docker/containerd/containerd.sock: timeout\". Reconnecting..." module=grpc docker
August 15th 2022, 12:34:41.045 time="2022-08-15T12:34:41.045317266Z" level=info msg="stopping event stream following graceful shutdown" error="<nil>" module=libcontainerd namespace=moby docker
August 15th 2022, 12:34:41.045 time="2022-08-15T12:34:41.045546124Z" level=info msg="stopping healthcheck following graceful shutdown" module=libcontainerd docker
August 15th 2022, 12:34:41.045 time="2022-08-15T12:34:41.045529653Z" level=info msg="Daemon shutdown complete" docker
August 15th 2022, 12:34:41.045 time="2022-08-15T12:34:41.045561321Z" level=info msg="stopping event stream following graceful shutdown" error="context canceled" module=libconta
@bmbferreira
bmbferreira / Translator.java
Created June 21, 2017 15:47
Class that calls google translate to translate a string from one language to another
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLEncoder;
import org.json.JSONArray;
/**
* @author Bruno Ferreira
@bmbferreira
bmbferreira / DeleteOrUpdateActive.java
Last active August 29, 2015 14:23
Small example to show something that should not be done with hibernate: reuse a session after an exception. It works with Hibernate 3 but not with version 4.
public void deleteOrUpdateActive() {
Session session = getSessionFactory().openSession();
Transaction t = session.beginTransaction();
Store s = (Store) session.get(Store.class, 1);
try {
session.delete(s);
t.commit();
} catch (ConstraintViolationException cException) {
t.rollback();
t = session.beginTransaction();
@bmbferreira
bmbferreira / DijkstraAlgorithm.rb
Last active August 29, 2015 13:56
Example of the Dijkstra Algorithm implementation written in Ruby. The input is an array of strings, each one consisting of a pair of letters separated by a dash, representing a two way connection between two nodes.
class Dijkstra
# Each pair "A-B" represents a two way connection between the node A and the node B.
# Example:
# d = Dijkstra.new(["A-B","B-C","C-D","D-E","E-B"])
# d.getShortestPath("A","D")
def initialize(connections)
@graph = Hash.new
for conn in connections
@bmbferreira
bmbferreira / Tic-Tac-Toe-Tomek.rb
Last active December 28, 2015 04:19
A solution in Ruby for the "Tic-Tac-Toe-Tomek" problem (https://code.google.com/codejam/contest/2270488/dashboard)
#a bi-dimensional array as seen on http://stackoverflow.com/questions/9144822/how-to-declare-a-two-dimensional-array-in-ruby
class SparseArray
attr_reader :hash
def initialize
@hash = {}
end
def [](key)
hash[key] ||= {}
@bmbferreira
bmbferreira / deleteAllFK.sql
Last active December 25, 2015 20:19
Delete all foreign keys (Oracle)
begin
for r in ( select table_name, constraint_name
from user_constraints
where constraint_type = 'R' )
loop
execute immediate 'alter table '||r.table_name
||' drop constraint '||r.constraint_name;
end loop;
end loop;