Skip to content

Instantly share code, notes, and snippets.

View vvasabi's full-sized avatar

Brad Chen vvasabi

View GitHub Profile
public class FaceletRenderer {
private FacesContext context;
public FaceletRenderer(FacesContext context) {
this.context = context;
}
/**
* Render the Facelets template specified.
@vvasabi
vvasabi / TouchEvents.pde
Created September 12, 2011 18:33
Touch Events in Processing.js
void setup() {
size(400, 300);
background(255);
}
void touchMove(TouchEvent touchEvent) {
// empty the canvas
noStroke();
fill(255);
rect(0, 0, 400, 300);
@vvasabi
vvasabi / PersistStateDataModel.java
Created May 15, 2012 04:42
PersistStateDataModel for programmatically manipulating the state of a <p:dataTable />
import java.util.Map;
import javax.el.ELContext;
import javax.el.ExpressionFactory;
import javax.el.ValueExpression;
import javax.faces.component.UINamingContainer;
import javax.faces.context.FacesContext;
import javax.servlet.ServletRequest;
import javax.servlet.http.HttpServletRequestWrapper;
@vvasabi
vvasabi / WrapRequestFilter.java
Created May 15, 2012 04:56
Filter that wraps request in CustomRequestWrapper
import java.io.IOException;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
@vvasabi
vvasabi / CustomRequestWrapper.java
Created May 15, 2012 04:57
A request wrapper that allows modification to parameter map
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletRequestWrapper;
@vvasabi
vvasabi / web.xml
Created May 15, 2012 04:58
web.xml installation for WrapRequestFilter
<!-- Wrap Request -->
<filter>
<filter-name>wrapRequestFilter</filter-name>
<filter-class>pkg.to.WrapRequestFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>wrapRequestFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
@vvasabi
vvasabi / mvn-ep.sh
Last active December 11, 2015 11:48
This script wraps around mvn -ep to take password without it being revealed.
#!/bin/bash
# This script wraps around mvn -ep to take password without it being revealed.
echo -n "Password: "
read -s password
echo ""
mvn -ep "$password"
@vvasabi
vvasabi / CutyCapt.cpp.diff
Last active February 24, 2016 11:28
Make it possible to make CutyCapt output pngs with transparent background. Just add --no-background=on in parameter.
Index: CutyCapt.cpp
===================================================================
--- CutyCapt.cpp (revision 10)
+++ CutyCapt.cpp (working copy)
@@ -363,6 +363,7 @@
" --js-can-access-clipboard=<on|off> Script clipboard privs (default: unknown)\n"
#if QT_VERSION >= 0x040500
" --print-backgrounds=<on|off> Backgrounds in PDF/PS output (default: off) \n"
+ " --no-background=<on|off> Transparent background (as opposed to white background) (default: off) \n"
" --zoom-factor=<float> Page zoom factor (default: no zooming) \n"
@vvasabi
vvasabi / BeanPropertyOverrideConfigurer.java
Created March 26, 2014 18:55
Instead of being able to override properties in any beans, this variant of PropertyOverrideConfigurer restricts property overriding to just 1 specified bean.
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.beans.factory.config.PropertyOverrideConfigurer;
public class BeanPropertyOverrideConfigurer extends PropertyOverrideConfigurer {
private String beanName;
public String getBeanName() {
return beanName;
@vvasabi
vvasabi / _font.scss
Last active August 29, 2015 14:02
IE8-compatible font style mixin that uses rem unit.
$root-font-size: 16px;
@mixin font($size, $line-height, $weight: null) {
font-size: $size; // IE fix
font-size: ($size / $root-font-size) * 1rem;
@if $weight != null {
font-weight: $weight;
}
line-height: $line-height;
}