Skip to content

Instantly share code, notes, and snippets.

View gist:8791072
private boolean resourceTransformed( List<ResourceTransformer> resourceTransformers, String name, InputStream is,
List<Relocator> relocators )
throws IOException
{
boolean resourceTransformed = false;
for ( ResourceTransformer transformer : resourceTransformers )
{
if ( transformer.canTransformResource( name ) )
{
View html5VideoAspectRatioAdjustment.coffee
# Just an example.
# @video is a direct reference to a '<video>' element.
# $() is assuming jQuery is being used in this example.
@video.addEventListener("loadedmetadata", (event) =>
actualRatio = @video.videoWidth/@video.videoHeight
targetRatio = $(@video).width()/$(@video).height()
adjustmentRatio = targetRatio/actualRatio
$(@video).css("-webkit-transform","scaleX(#{adjustmentRatio})")
)
View CurrentUserLoggingFilter.java
public class CurrentUserLoggingFilter implements Filter {
public static final String MDC_CURRENT_ACCOUNT_ID_KEY = "CurrentAccountId";
@Context
HttpContext context;
@Override
public void init(FilterConfig filterConfig) throws ServletException { /* unused */ }
View CurrentUserLoggingFilter.java
public class CurrentUserLoggingFilter implements Filter {
public static final String MDC_CURRENT_ACCOUNT_ID_KEY = "CurrentAccountId";
@Context
HttpContext context;
@Override
public void init(FilterConfig filterConfig) throws ServletException { /* unused */ }
View gist:11269283
<html>
<head>
<style type="text/css">
table table {
width: 600px !important;
}
table div + div { /* main content */
width: 65%;
float: left;
}
View gist:c9b7c774a209cb9280a0
/* ====================================================================
* eldarion-ajax-core.js v0.10.0
* ====================================================================
* Copyright (c) 2013, Eldarion, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice,
View SpelFreemarkerTemplateDirective.java
public class SpelFreemarkerTemplateDirective implements TemplateDirectiveModel {
SpelEvaluator spelEvaluator;
@Required
public void setSpelEvaluator(SpelEvaluator spelEvaluator) {
this.spelEvaluator = spelEvaluator;
}
@Override
public void execute(Environment env, @SuppressWarnings("rawtypes") Map params, TemplateModel[] loopVars,
View gist:2f5a0c7f8f3dcdca1543
input {
stdin { }
file {
type => "applogs"
# Wildcards work, here :)
path => [ "/home/alee/workspaces/java-workspaces/elasticsearch-example/graph-presenter/logs/*.log" ]
}
}
View gist:2242a1149f6413576353
public abstract class SpringApplication<T extends SpringConfiguration> extends Application<T> {
/**
* When the application runs, this is called after the {@link io.dropwizard.Bundle}s are run. Override it to add
* providers, resources, etc. for your application.
*
* @param configuration the parsed {@link io.dropwizard.Configuration} object
* @param environment the application's {@link io.dropwizard.setup.Environment}
* @throws Exception if something goes wrong
*/
View optimizing_intellij_idea_on_openjdk_8_(64-bit)
This is a list of tweaks to make IntelliJ IDEA work better with OpenJDK 8 (64-bit). Refer to https://docs.oracle.com/javase/8/docs/technotes/guides/2d/flags.html for the details of the options used below.
Note that, the performance boost achieved via the OpenGL-based pipeline is made possible by using the latest version (e.g., mesa-dri-drivers-10.3.2-1.20141028.fc21.x86_64) of the open-source Radeon driver (for ATi graphics cards). This might vary based on the types of graphics cards and drivers.
1. Text Anti-aliasing
In $IDEA_HOME/bin/idea64.vmoptions, change
-Dawt.useSystemAAFontSettings=lcd