Skip to content

Instantly share code, notes, and snippets.

View pydawan's full-sized avatar

Thiago Monteiro pydawan

View GitHub Profile
@pydawan
pydawan / GradleCheatsheet.md
Created January 6, 2019 15:55 — forked from jiffle/GradleCheatsheet.md
Cheatsheet of Gradle Commands and Config

Command Cheatsheet

  • Convert Maven build to gradle

    gradle init

  • Initialise new project folder structure (Java example)

    gradle init --type java-library

@pydawan
pydawan / models.java
Created January 25, 2019 01:19 — forked from leefsmp/models.java
Basic RESTful API from a Java servlet
package com.autodesk.adn.viewanddata;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Collection;
import java.util.HashMap;
import java.util.UUID;
import javax.servlet.ServletException;
@pydawan
pydawan / comparator-min.js
Created February 16, 2019 10:31 — forked from efeminella/comparator-min.js
Simple Comparator API for JavaScript
var Comparator=Comparator||(function(){var c=function(g,f){return this[g]===f};var a=function(f){if(!this.hasOwnProperty(f)){this[f]=undefined}};var b=function(g,m,f){var k=g.prototype,o=(f?f.length:0),j=0,l,h;for(j;j<o;j++){l=f[j];h="is"+l.replace(/^./,l.match(/^./)[0].toUpperCase());if(k[h]===undefined){k[h]=(function(){return c}(m,l))}}};var d=function(g,k,f){var i=g.prototype,h,j;for(h in f){j=f[h];if(i[h]===undefined){i[h]=(function(){return c}(k,j))}}};var e=function(g,h,f){if(g.constructor!=Object){a.call(g.prototype,h);if(Object.prototype.toString.call(f)==="[object Array]"){return b(g,h,f)}return d(g,h,f)}else{throw new Error("Attempting to augment Object prototype")}};return{each:e}}());
@pydawan
pydawan / zoologicMonitor.html
Created February 20, 2019 01:24 — forked from a21ns1g4ts/zoologicMonitor.html
Exemplo de composição usando funções contrutoras.
<script src="catMonitor.js"></script>
<script lang="javascript">
const dog1 = makeDog(
{
name:"Mark Pure object" ,
id: 1 ,
}
);
dog1.fly();
@pydawan
pydawan / convertUTF8toISO-description.txt
Created February 27, 2019 12:34 — forked from luis-fss/convertUTF8toISO-description.txt
Convertendo de UTF-8 para ISO-8859-1 em Java: A solução definitiva
Recentemente enfrentei problemas em um aplicativo Android que desenvolvi, o qual se comunica com o banco de dados de um dos sistemas da empresa, codificado em ISO-8859-1 (Firebird) através de um web service.
Os dados eram gravados de forma errada, muitas vezes truncavam e as vezes apareciam caracteres estranhos.
Depois de algumas tentativas, cheguei até a seguinte solução:
@pydawan
pydawan / postgre.gradle
Created March 21, 2019 06:23 — forked from taichi/postgre.gradle
enable PostgreSQL configuration to Wildfly using Gradle.
dependencies { runtime 'org.postgresql:postgresql:9.2-1003-jdbc4' }
task installPostgreSQL(type: Copy) {
def postgreJar = configurations.runtime.find { it.name.contains('postgresql') }
def moduleDir = "$jbossHome/modules/system/layers/base/org/postgresql/main"
from postgreJar
into moduleDir
doLast {
@pydawan
pydawan / Python Books.md
Created March 22, 2019 01:44
Python Books

This is a collection of books that I've researched, scanned the TOCs of, and am currently working through.  The books are selected based on quality of content, reviews, and reccommendations of various 'best of' lists.

The goal of this collection is to promote mastery of generally applicable programming concepts.

Most topics are covered with Python as the primary language due to its conciseness, which is ideal for learning & practicing new concepts with minimal syntactic boilerplate.

JavaScript & Kotlin are listed in the Tooling section; as they allow extension of VS Code and the IntelliJ suite of IDEs, which cover most development needs.

 

@pydawan
pydawan / GroovierReport.groovy
Created April 27, 2019 11:49 — forked from osmanizbat/GroovierReport.groovy
Groovier reports with groovy & jasperreports
import java.awt.Color;
import net.sf.jasperreports.engine.*;
import net.sf.jasperreports.engine.design.*;
import net.sf.jasperreports.engine.type.*;
import net.sf.jasperreports.view.JasperViewer
class GroovierReport {
static void main(String[] args) {
def builder = new ObjectGraphBuilder()
@pydawan
pydawan / java-exception-handling-best-practices.md
Created May 1, 2019 18:37 — forked from raineorshine/java-exception-handling-best-practices.md
5 Great Resources for Exception Handling Best Practices in Java

General Tip

"The trick is to catch exceptions at the proper layer, where your program can either meaningfully recover from the exception and continue without causing further errors, or provide the user with specific information, including instructions on how to recover from the error. When it is not practical for a method to do either of these, simply let the exception go so it can be caught later on and handled at the appropriate level."

Resources

Advantages of Exceptions
Excellent example of separating error-handling code from program logic

Three Rules for Effective Exception Handling
Longer explanation and case study of exception use, including the basic principles of "throw early" and "catch late". Clear and thorough.

@pydawan
pydawan / clean-up-boot-partition-ubuntu.md
Created May 16, 2019 22:12 — forked from ipbastola/clean-up-boot-partition-ubuntu.md
Safest way to clean up boot partition - Ubuntu 14.04LTS-x64, Ubuntu 16.04LTS-x64

Safest way to clean up boot partition - Ubuntu 14.04LTS-x64, Ubuntu 16.04LTS-x64

Reference

Case I: if /boot is not 100% full and apt is working

1. Check the current kernel version

$ uname -r