Skip to content

Instantly share code, notes, and snippets.

View matheustardivo's full-sized avatar

Matheus Tardivo matheustardivo

View GitHub Profile
@matheustardivo
matheustardivo / cs_go_console_commands.md
Last active February 12, 2018 16:02
Counter-Strike: Global Offensive console commands

Counter-Strike: Global Offensive console commands

Headshot only FFA bot training

bot_quota 20
sv_cheats 1
sv_infinite_ammo 1
mp_teammates_are_enemies 1
mp_damage_headshot_only 1

mp_freezetime 1

@matheustardivo
matheustardivo / README.md
Last active April 29, 2016 13:31
Cluster ssh tool for Terminal.app

Cluster ssh tool for Terminal.app

O primeiro passo é instalar o Cluster ssh tool for Terminal.app ou csshX:

brew install csshx

Depois, incluir o script abaixo no seu .bashrc:

function server() {
@matheustardivo
matheustardivo / lexicographic_paths.rb
Last active January 15, 2016 15:10
Lexicographic paths
# Ruby version from https://github.com/derekhh/HackerRank/blob/master/mathematics/combinatorics/lexicographic-steps.cpp
# Build the 'Lower Pascal matrix'
# http://rosettacode.org/wiki/Pascal_matrix_generation#Ruby
ng = (g = 0..20).collect{ [] }
g.each { |i| g.each { |j| ng[i][j] = j == 0 ? 1 : i < j ? 0 : ng[i - 1][j - 1] + ng[i - 1][j] } }
# Uncomment the line bellow to print the matrix
# ng.each { |i| i.each { |j| print "#{j}\t" }; puts }
t = gets.chomp.to_i
@matheustardivo
matheustardivo / App.java
Created April 14, 2013 20:07
Prosdac report spreadsheet reader
package net.tardivo.prosoft.excel.reader;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Pattern;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
@matheustardivo
matheustardivo / DatabaseIntegration.java
Created December 18, 2012 17:28
Testing with dbunit
package com.walmart.customer.services.frontend.domain.test;
import java.sql.Connection;
import javax.sql.DataSource;
import org.dbunit.database.DatabaseConnection;
import org.dbunit.database.IDatabaseConnection;
import org.dbunit.dataset.IDataSet;
import org.dbunit.dataset.xml.FlatXmlDataSetBuilder;
@matheustardivo
matheustardivo / CorreiosCarrierTracker.java
Created October 29, 2012 13:00
Exemplo de código para fazer o tracking do site dos Correios.
import java.io.DataInputStream;
import java.io.File;
import java.io.FileWriter;
import java.io.PrintStream;
import java.net.URL;
import java.net.URLConnection;
public class CorreiosCarrierTracker {
public static void main(String[] args) {
@matheustardivo
matheustardivo / correios.xml
Created October 29, 2012 12:59
Exemplo de resposta do tracking dos Correios.
<?xml version="1.0" encoding="iso-8859-1" ?>
<sroxml>
<versao>1.0</versao>
<qtd>1</qtd>
<TipoPesquisa>Lista de Objetos</TipoPesquisa>
<TipoResultado>Todos os eventos</TipoResultado>
<objeto>
<numero>SW371675211BR</numero>
<evento>
<tipo>BDE</tipo>
@matheustardivo
matheustardivo / HelloYouPortlet.java
Created October 23, 2012 13:22
Exemplo de portlet do Liferay *SUPER* simples ;)
package com.liferayinaction.portlet;
import java.io.IOException;
import javax.portlet.ActionRequest;
import javax.portlet.ActionResponse;
import javax.portlet.GenericPortlet;
import javax.portlet.PortletException;
import javax.portlet.PortletMode;
import javax.portlet.PortletPreferences;
@matheustardivo
matheustardivo / validador_cpf.rb
Created April 26, 2012 13:08
Validador de CPF
class ValidadorCPF
REGEX = /\A(\d{3}\.?){2}\d{3}\-?\d{2}\Z/
def self.valido?(cpf)
return false unless REGEX =~ cpf
arr = cpf.scan(/\d/).take(9)
arr << calcular_dv(arr)
@matheustardivo
matheustardivo / gist:2376326
Created April 13, 2012 11:54
JAXB Marshaller snippet
JAXBContext jaxbContext = JAXBContext.newInstance(Profile.class);
Marshaller marshaller = jaxbContext.createMarshaller();
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
marshaller.marshal(profile, System.out);