Skip to content

Instantly share code, notes, and snippets.

View jnwelzel's full-sized avatar
💻
[object Object]

Jonathan Welzel jnwelzel

💻
[object Object]
View GitHub Profile
@jnwelzel
jnwelzel / new_injection.js
Last active August 11, 2017 15:31
Injection
//generate the javascript content of method cloudpassSetUsername to inject into the current page
function injectSetUsernameFunc(usernameFieldIsId,usernameField){
var js = 'window.cloudpassSetUsername = function(username){';
if(usernameFieldIsId){
js += 'forceChangeField( document.getElementById("'+usernameField+'"), username);';
}else{
js += 'forceChangeField( document.getElementsByName("'+usernameField+'")[0], username);';
}
js += '};';
return js;
@jnwelzel
jnwelzel / backbone_mixin.js
Created June 6, 2014 16:53
Backbone mixin for enabling Reactjs components to respond to Backbone objects/collections changes
// An example generic Mixin that you can add to any component that should react
// to changes in a Backbone component. The use cases we've identified thus far
// are for Collections -- since they trigger a change event whenever any of
// their constituent items are changed there's no need to reconcile for regular
// models. One caveat: this relies on getBackboneModels() to always return the
// same model instances throughout the lifecycle of the component. If you're
// using this mixin correctly (it should be near the top of your component
// hierarchy) this should not be an issue.
var BackboneMixin = {
componentDidMount: function() {
import org.scribe.builder.api.DefaultApi10a;
import org.scribe.model.OAuthConstants;
import org.scribe.model.OAuthRequest;
import org.scribe.model.Verb;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import branda.media.exception.CacheException;
public class OAuthRequestValidator {
#!/bin/bash
JERSEY_VERSION=2.7
HK2_VERSION=2.3.0-b03
JAVASSIST_VERSION=3.18.1-GA
MODULES_DIR=`pwd`/modules
OSGI_CACHE_DIR=`pwd`/domains/domain1/osgi-cache/felix
processArtifact() {
@jnwelzel
jnwelzel / GsonProvider.java
Created March 10, 2014 14:36 — forked from hstaudacher/GsonProvider.java
Integrating Gson into a JAX-RS application to replace the other shitty default providers
import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.lang.annotation.Annotation;
import java.lang.reflect.Type;
@jnwelzel
jnwelzel / derby_u51_workaround.md
Created March 7, 2014 14:20
Workaround for starting Derby network server under JDK 7_u51 and its new security policies
  1. Grab the policy file here
  2. Use the following command $ java -Djava.security.manager -Djava.security.policy=/home/jwelzel/Downloads/1010_server.policy -Dderby.security.port=1527 -Dderby.install.url=file:/home/jwelzel/apps/db-derby-10.10.1.1-bin/lib/ -cp "lib/*" org.apache.derby.drda.NetworkServerControl start
@jnwelzel
jnwelzel / recursive-delete-file-type-in-linux.md
Created February 27, 2014 18:14
recursive-delete-file-type-in-linux

#First "cd" to the top directory you want to start in. (Don't be stupid and run this from your root....)

To get a confirmation for every file use: find . -type f -name "*.bak" -exec rm -i {} \;

Or if you're feeling confident use: find . -type f -name "*.bak" -exec rm -f {} \;

@jnwelzel
jnwelzel / Kb.java
Created February 27, 2014 17:01
wow
// 2MB
if (picture.length > 2 * 1024 * 1024) {
throw new FDNFileTooLargeException("2MB.");
}
@jnwelzel
jnwelzel / maven_snippets.md
Last active January 4, 2016 10:29
Maven snippets

####Local archetype Execute this inside your archetype project $ mvn install archetype:update-local-catalog. After that, create a new project using the newly installed archetype by using $ mvn archetype:generate -DarchetypeCatalog=local, choose the archetype number corresponding to the one you just installed and follow the on screen instructions. Here's a good example of an archetype to get you started.

@jnwelzel
jnwelzel / Bean.java
Last active February 8, 2024 21:56
Simple generic DAO structure for Java. Note that the interface takes two generic parameters, one for the primary key type, and the second for the bean type, which uses the same primary key. This enables you to use any kind of object as a primary key, making your code very flexible. This is a good behavior especially if you use JPA embedded ids (…
@MappedSuperclass
public abstract class Bean<PK extends Serializable> implements Serializable {
private static final long serialVersionUID = 1L;
@Version
@Column(name = "VERSION", nullable = false)
private Long version;
public Bean(PK id, Long version) {