Skip to content

Instantly share code, notes, and snippets.

@jpgreenwald
jpgreenwald / gist:5178897
Created March 16, 2013 23:59
Reasonable Defaults for os x
~/.bash_profile
alias ll='ls -aFhlG'
PATH="/Applications/Postgres.app/Contents/MacOS/bin:$PATH"
PATH="/usr/local/mysql/bin:$PATH"
alias psql='psql -d postgres'
#PS1="\[\033[G\]$PS1"
### Added by the Heroku Toolbelt
#!/bin/bash
# NOTE: this is an OSX launchd wrapper shell script for Tomcat (to be placed in $CATALINA_HOME/bin)
CATALINA_HOME=/Users/username/tomcat
function shutdown() {
date
echo "Shutting down Tomcat"
$CATALINA_HOME/bin/catalina.sh stop
@jpgreenwald
jpgreenwald / gist:5897289
Last active December 19, 2015 04:28
OSX Defaults
defaults write com.apple.dashboard mcx-disabled -boolean YES
defaults write NSGlobalDomain AppleShowScrollBars -string "Always"
defaults write NSGlobalDomain AppleShowAllExtensions -bool true
defaults write com.apple.finder QLEnableTextSelection -bool true
killall Dock
#To fix Apache Benchmark (ab):
brew install pcre
@jpgreenwald
jpgreenwald / persistence.xml
Created July 6, 2013 00:39
Java EE persistence.xml
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
<persistence-unit name="db" transaction-type="JTA">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<jta-data-source>jdbc/DbPool</jta-data-source>
<exclude-unlisted-classes>false</exclude-unlisted-classes>
</persistence-unit>
</persistence>
@jpgreenwald
jpgreenwald / GuavaHack.java
Created July 6, 2013 00:41
Google Guava does not work well with Java EE 7 containers like glassfish 4. This is a producer hack to allow for deployment.
package com.swsandbox.hack;
import com.google.common.collect.ImmutableSet;
import com.google.common.util.concurrent.Service;
import javax.enterprise.context.ApplicationScoped;
import javax.enterprise.inject.Produces;
/**
* This is included to bypass the Java EE 7 issue with Google Guava and CDI:
@jpgreenwald
jpgreenwald / snappyjava stacktrace
Created July 6, 2013 01:02
When deploying the cassandra java driver to glassfish there is an Invocation Exception for snappy java missing.
When you see this:
at java.lang.Thread.run(Thread.java:724)
Caused by: java.lang.UnsatisfiedLinkError: no snappyjava in java.library.path
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1878)
at java.lang.Runtime.loadLibrary0(Runtime.java:849)
at java.lang.System.loadLibrary(System.java:1087)
at org.xerial.snappy.SnappyNativeLoader.loadLibrary(SnappyNativeLoader.java:52)
... 114 more]]
@jpgreenwald
jpgreenwald / InjectionServlet.java
Created July 6, 2013 17:20
It seems to be impossible to use CDI within a JAX-RS 2.0 ContainerRequestFilter, but it is possible to first use a WebFilter to obtain the service and then pass it along via attributes.
package com.swsandbox.resource;
import com.swsandbox.service.UserService;
import javax.inject.Inject;
import javax.servlet.*;
import javax.servlet.annotation.WebFilter;
import java.io.IOException;
@WebFilter(urlPatterns = "/*")
@jpgreenwald
jpgreenwald / gist:5942374
Created July 7, 2013 05:05
Proper way to fetch remote changes to a git repo
git fetch origin
git checkout master
git merge origin/master
@jpgreenwald
jpgreenwald / gist:5979686
Created July 11, 2013 22:07
Oracle Upsert using merge
MERGE INTO target_name T USING
( select 1 from dual) S ON
( clause_that_finds_record inside T )
WHEN MATCHED THEN UPDATE
SET update_what_you_want_in_T
WHEN NOT MATCHED THEN
INSERT(
stuff_in_t
) VALUES( ...values... );
@jpgreenwald
jpgreenwald / gist:6398582
Created August 31, 2013 14:29
dropbox referral
http://db.tt/OvdCg4Fe