Skip to content

Instantly share code, notes, and snippets.

View vvasabi's full-sized avatar

Brad Chen vvasabi

View GitHub Profile
@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 / 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 / antigremlin.php
Created October 7, 2014 18:30
Remove Photoshop gremlins. Use it like so: pbpaste | php antigremlin.php | pbcopy.
<?php
function remove_gremlins($str) {
$cleaned = '';
for ($i = 0, $max = strlen($str); $i < $max; $i++) {
$char_str = substr($str, $i, 1);
$char = ord($char_str);
if (($char >= 32) || ($char == 13)) { // new line or printable chars
$cleaned .= $char_str;
}
@vvasabi
vvasabi / makefast.sh
Last active August 29, 2015 14:04
Emulate slower Internet speed. (Apple also provides a free Network Link Conditioner pref pane that does the same thing.)
#!/bin/bash
# Make Internet connection fast again
sudo ipfw delete 1
sudo ipfw delete 2
sudo ipfw delete 3
sudo ipfw delete 4
@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;
}
@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;