Skip to content

Instantly share code, notes, and snippets.

@mallim
mallim / Try.java
Created October 21, 2013 02:23
Jersey @put and @delete with Backbone.emulateHTTP set to true
import com.sun.jersey.api.view.Viewable;
import org.apache.log4j.Logger;
import org.springframework.stereotype.Service;
import javax.ws.rs.*;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import java.util.Map;
@Path("/try")

API workthough

  1. Open a browser

    # start an instance of firefox with selenium-webdriver
    driver = Selenium::WebDriver.for :firefox
    # :chrome -> chrome
    # :ie     -> iexplore
    
  • Go to a specified URL
@mallim
mallim / stream_logging.js
Created June 22, 2014 01:02
Console logging stream. Useful for node stream debugging
var es = require('event-stream');
var logger = es.mapSync(function (data) { //create a stream that logs to stderr,
console.error(data);
return data;
});
@mallim
mallim / WebSecurityConfig.java
Created June 27, 2014 13:31
Spring Boot's Spring Security Web Security Config
import org.sbangular.security.UnauthorisedEntryPoint;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.autoconfigure.security.SecurityProperties;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.annotation.Order;
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.builders.WebSecurity;
.exec(http("Goto Your Desired URL")
.get("http://THIS_SHOULD_BE_YOUR_URL")
.check(
status.is(200),
bodyString.saveAs("responseBody")
)
)
.exec(
session => {
// You can do whatever you want with the string
.exec(http("PERFORM A FILE UPLOAD")
.post("YOUR_DESIRED_URL_FOR_UPLOAD")
.body(ELFileBody("THE_FILE_TO_UPLOAD"))
.check(
status.is(200),
).asMultipartForm)
@mallim
mallim / ErrorLog.java
Created April 7, 2015 01:40
Stacktrace of Error Encountered @ Weblogic 12c, JDK 1.7, Eclipse 2.6.0
####<Apr 6, 2015 7:42:25 PM SGT> <Error> <Class Loaders> <ISPS-APP> <AdminServer> <[STANDBY] ExecuteThread: '4' for queue: 'weblogic.kernel.Default (self-tuning)'> <<WLS Kernel>> <> <> <1428320545119> <BEA-2162500> <Class, org.eclipse.persistence.internal.indirection.jdk8.IndirectCollectionsProvider, was compiled with an incompatible version of Java. Make sure that all the classes needed by the application have been compiled with a compatible java version. java.lang.UnsupportedClassVersionError: org/eclipse/persistence/internal/indirection/jdk8/IndirectCollectionsProvider : Unsupported major.minor version 52.0
java.lang.UnsupportedClassVersionError: org/eclipse/persistence/internal/indirection/jdk8/IndirectCollectionsProvider : Unsupported major.minor version 52.0
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at weblogic.utils.classloaders.GenericClassLoader.defineCl
@mallim
mallim / SQLiteDialect.java
Created January 15, 2016 08:38 — forked from virasak/SQLiteDialect.java
SQLite dialect for Hibernate
/*
* The author disclaims copyright to this source code. In place of
* a legal notice, here is a blessing:
*
* May you do good and not evil.
* May you find forgiveness for yourself and forgive others.
* May you share freely, never taking more than you give.
*
*/
package org.hibernate.dialect;
@mallim
mallim / logstash.conf
Created July 19, 2016 03:15
Logstash config for Spring Boot's default logging
input {
file {
type => "java"
tags => [ "fornax-data-share-eureka" ]
# Logstash insists on absolute paths...
path => "D:/fornax-data-share-runtime/eureka/fornax-data-share-eureka.log"
codec => multiline {
pattern => "^%{YEAR}-%{MONTHNUM}-%{MONTHDAY} %{TIME}.*"
negate => "true"
what => "previous"
\documentclass[
fromalign=left, % letter head on the right
fromphone, % show phone number
fromaddress,
fromemail, % show email
version=last, % latest version of KOMA letter
refline=dateleft, % aligns both the city and the date to the left
backaddress=off, % Sender address in this window
foldmarks=on, % Print foldmarks
parskip=full,