Skip to content

Instantly share code, notes, and snippets.

@cjmamo
cjmamo / event(2).rb
Last active December 20, 2015 02:59
The Rails Way to Search Filtering
class Event < ActiveRecord::Base
attr_accessible :locality, :country, :date, :title, :tags
has_and_belongs_to_many :tags
def self.in_country(country)
if country.present?
where('country = ?', country)
else
scoped
@cjmamo
cjmamo / CommentResource.java
Last active April 24, 2018 18:15
How To Publish a WADL with Mule's REST Router Module
package org.ossandme;
import javax.ws.rs.*;
@Path("/{userid}/comments/{title}/feed")
public interface CommentResource {
@GET
public String retrieveComment(@PathParam("userid") String userID, @PathParam("title") String title);
@cjmamo
cjmamo / ApplicationController.java
Last active December 14, 2015 09:39
Posting & Processing JSON with jQuery & Spring MVC
...
@Controller
public class ApplicationController {
@RequestMapping(value = "/create-client", method = RequestMethod.GET)
public String getCreateClientForm() {
return "NewClientForm";
}
@RequestMapping(headers = "Content-Type=application/json", value = "submit-create-client", method = RequestMethod.POST)
@cjmamo
cjmamo / Callback.java
Last active December 11, 2015 09:08
ReplyTo in ZeroMQ using WS-Addressing
package org.ossandme.client;
import javax.jws.WebParam;
import javax.jws.WebService;
import javax.xml.ws.RequestWrapper;
@WebService
public class Callback {
@RequestWrapper(localName = "sayHiResponse", targetNamespace = "http://apache.org/hello_world_soap_zmq/types")
@cjmamo
cjmamo / Client.java
Last active December 11, 2015 03:48
SOAP over ZeroMQ with Apache CXF
package org.ossandme.client;
import org.apache.hello_world_soap_zmq.Greeter;
import org.apache.hello_world_soap_zmq.SOAPService;
public final class Client {
public static void doOperation() throws Exception {
// Create client
package org.opensourcesoftwareandme;
import javax.ws.rs.core.Application;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
public class HelloWorldApp extends Application {
public Set<Class<?>> getClasses() {
@cjmamo
cjmamo / HelloWorldImpl(1).java
Last active December 9, 2015 17:49
Demystifying Apache CXF: A Hello World App
package org.opensourcesoftwareandme;
public class HelloWorldImpl{
public String sayHi(String text) {
return "Hello " + text;
}
}
...
@Test
public void testMapping() throws Exception {
// Hibernate configuration
Map<String, String> hibernateProperties = new HashMap<String, String>();
hibernateProperties.put("hibernate.dialect", "org.hibernate.dialect.DerbyTenSevenDialect");
hibernateProperties.put("hibernate.connection.driver_class", "org.apache.derby.jdbc.EmbeddedDriver");
hibernateProperties.put("hibernate.connection.url", "jdbc:derby:target/test-database/database;create=true");
hibernateProperties.put("hibernate.hbm2ddl.auto", "create");
@cjmamo
cjmamo / CalculatorServiceTestCase.java
Created October 18, 2012 21:48
Testing Web Services from JUnit using SoapUI
...
public class CalculatorServiceTestCase {
@Test
public void testCalculatorService() throws Exception {
SoapUITestCaseRunner testCaseRunner = new SoapUITestCaseRunner();
SoapUIMockServiceRunner mockServiceRunner = new SoapUIMockServiceRunner();
testCaseRunner.setProjectFile("src/test/resources/calculator-soapui-project.xml");
@cjmamo
cjmamo / gist:3330498
Last active October 8, 2015 12:17
Building ZeroMQ for Android
ctx.cpp:26:15: fatal error: new: No such file or directory
compilation terminated.
make[3]: *** [libzmq_la-ctx.lo] Error 1
make[2]: *** [all] Error 2
make[1]: *** [all-recursive] Error 1
make: *** [/opt/android-jzmq/output-arm/lib/libzmq.a] Error 2