Skip to content

Instantly share code, notes, and snippets.

Jonathan Welzel jnwelzel

Block or report user

Report or block jnwelzel

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@jnwelzel
jnwelzel / backbone_mixin.js
Created Jun 6, 2014
Backbone mixin for enabling Reactjs components to respond to Backbone objects/collections changes
View backbone_mixin.js
// 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() {
View OAuthRequestValidator.java
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 {
View update-jersey-in-gf.sh
#!/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 Mar 10, 2014 — forked from hstaudacher/GsonProvider.java
Integrating Gson into a JAX-RS application to replace the other shitty default providers
View GsonProvider.java
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 Mar 7, 2014
Workaround for starting Derby network server under JDK 7_u51 and its new security policies
View derby_u51_workaround.md
  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 Feb 27, 2014
recursive-delete-file-type-in-linux
View recursive-delete-file-type-in-linux.md

#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 {} \;

View Kb.java
// 2MB
if (picture.length > 2 * 1024 * 1024) {
throw new FDNFileTooLargeException("2MB.");
}
View maven_snippets.md

####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 Aug 11, 2017
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 (…
View Bean.java
@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) {
@jnwelzel
jnwelzel / perguntas_empresa.md
Last active Jan 2, 2016
Perguntas a serem feitas pelo funcionário na hora da contratação que lá na frente podem evitar dores de cabeça.
View perguntas_empresa.md
  1. Vou ter que abrir outra conta bancária só pra receber o salário de vocês?
  2. Empresa dispõe de estacionamento coberto? Pra mim, que tenho moto, isso é essencial.
  3. Se não quiserem te dar tempo pra pensar na proposta e ficarem tentando te forçar a dar logo uma resposta se vai aceitar o cargo ou não, tome cuidado porque essa empresa provavelmente é ejaculação precoce e vai botar pressão p caramba. Esteja ciente disso.
You can’t perform that action at this time.