Skip to content

Instantly share code, notes, and snippets.

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 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 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
View DefaultMethodProxyExample.java
package labs;
import java.lang.invoke.MethodHandles;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import java.util.Arrays;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import java.util.stream.Collectors;
View golang-setup.sh
brew install go
mkdir $HOME/go
echo -e "
export GOPATH=$HOME/go
export GOROOT=$(go env GOROOT)
export PATH=$PATH:$GOPATH/bin:$GOROOT/bin" >> $HOME/.bash_profile
brew install hg
source $HOME/.bash_profile
go get code.google.com/p/go.tools/cmd/godoc
go get code.google.com/p/go.tools/cmd/vet
View gist:f72aeed2bd9e966175df

Setting up Vim as your Go IDE

The final IDE

Intro

I've been wanting to do a serious project in Go. One thing holding me back has been a my working environment. As a huge PyCharm user, I was hoping the Go IDE plugin for IntelliJ IDEA would fit my needs. However, it never felt quite right. After a previous experiment a few years ago using Vim, I knew how powerful it could be if I put in the time to make it so. Luckily there are plugins for almost anything you need to do with Go or what you would expect form and IDE. While this is no where near comprehensive, it will get you writing code, building and testing with the power you would expect from Vim.

Getting Started

I'm assuming you're coming with a clean slate. For me this was OSX so I used MacVim. There is nothing in my config files that assumes this is the case.