Skip to content

Instantly share code, notes, and snippets.

// Node.js CheatSheet.
// Download the Node.js source code or a pre-built installer for your platform, and start developing today.
// Download: http://nodejs.org/download/
// More: http://nodejs.org/api/all.html
// 0. Synopsis.
// http://nodejs.org/api/synopsis.html
@jpgreenwald
jpgreenwald / gist:7088422
Created October 21, 2013 18:16
scroll speed fix in ubuntu while on mac trackpad
sudo modprobe hid_magicmouse scroll-speed=1 scroll-acceleration=4
# First verify the version of Java being used is not SunJSK.
java -version
# Get the latest Sun Java SDK from Oracle http://www.oracle.com/technetwork/java/javase/downloads/jdk-7u1-download-513651.html
wget http://download.oracle.com/otn-pub/java/jdk/7u1-b08/jdk-7u1-linux-i586.rpm
# Rename the file downloaded, just to be nice
mv jdk-7u1-linux-i586.rpm\?e\=1320265424\&h\=916f87354faed15fe652d9f76d64c844 jdk-7u1-linux-i586.rpm
# Install Java
@jpgreenwald
jpgreenwald / gist:6398582
Created August 31, 2013 14:29
dropbox referral
http://db.tt/OvdCg4Fe
@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: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 / 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 / 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 / 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 / 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>