Skip to content

Instantly share code, notes, and snippets.

View FagnerMartinsBrack's full-sized avatar
🎯
Focusing

Fagner Brack FagnerMartinsBrack

🎯
Focusing
View GitHub Profile
public class ResizingAlgorithm {
private ImageDimension image;
public ResizingAlgorithm( int width, int height ) {
this.image = new ImageDimension( width, height );
}
/**
* Redimensiona a largura e o tamanho proporcionavelmente
*/
public class ResizingAlgorithm {
private ImageDimension image;
public ResizingAlgorithm( int width, int height ) {
this.image = new ImageDimension( width, height );
}
public ImageDimension resizeTo( int width ) {
double factor = getScaleFactor( width );
int height = ( int )( image.getHeight() * factor );
@FagnerMartinsBrack
FagnerMartinsBrack / EarthLocation.java
Last active November 4, 2015 13:56
EarthLocation class
/**
* @author Fagner Brack
*/
public class EarthLocation {
private double latitude;
private double longitude;
private final int EARTH_RADIUS_KM = 6371;
public EarthLocation( double latitude, double longitude ) {
@FagnerMartinsBrack
FagnerMartinsBrack / EarthLocationTest.java
Last active November 4, 2015 13:56
EarthLocationTest
public class EarthLocationTest {
@Test
public void test_southwest_hemisphere_distances() {
EarthLocation portoAlegre = new EarthLocation( -30.0277, -51.2287 );
EarthLocation manaus = new EarthLocation( -3.1064, -60.0264 );
int expected = 3133;
int distance = portoAlegre.getDistanceOf( manaus );
package org.megafone.web.assets;
import javax.annotation.ManagedBean;
import javax.ejb.EJB;
import javax.servlet.ServletContext;
import org.megafone.core.service.city.CityReader;
import org.megafone.core.service.user.UserReader;
import org.ocpsoft.logging.Logger.Level;
import org.ocpsoft.rewrite.annotation.RewriteConfiguration;
import java.util.*;
import java.lang.*;
public class PersonExecutor {
public static void main( String[] arguments ){
Person john = new Person();
Person mike = new Person();
john.setName( "John" );
mike.setName( "Mike" );
@FagnerMartinsBrack
FagnerMartinsBrack / gist:4928e441f2fe9f140d68
Created March 15, 2015 20:25
Fagner`s Front-End Craziness Checklist

Commons issues that make me lose a few minutes to a few hours to find out the cause.

Something only updates in IE when I open developer tools
  1. Check the cache - Ajax GET requests are always cached by default in IE, but not cached by default when developer tools is open.
@FagnerMartinsBrack
FagnerMartinsBrack / Client.java
Last active November 4, 2015 13:56
Notification OO Design Draft
public static void main( String[] args ) {
NotificationService service = new NotificationService();
// Imprime todas as notificações no view
service.listNotifications();
}
@FagnerMartinsBrack
FagnerMartinsBrack / Client.java
Last active November 4, 2015 13:57
Notification Facade OO design draft
{
NotificacaoContent content = /* ... constrói teu conteúdo aqui */;
notificacaoFacade.notify( content, beanManager );
}
@FagnerMartinsBrack
FagnerMartinsBrack / IdealWorld.js
Last active May 2, 2016 08:36
(Medium) Promises Are Not Proxies - Ideal World
try {
const soccerMatches = fetchSoccerMatchesFromResource( ... );
const soccerResults = fetchSoccerResultsFromResource( ... );
const detailedMatches = soccerMatches.map(function( match ) {
return {
name: match.name,
score: findScoreForMatch( match, soccerResults )
};
});