Skip to content

Instantly share code, notes, and snippets.

Avatar

Ajay Nadathur ajaykumarns

View GitHub Profile
View ProxiedProductClient.java
public class ProxiedProductClient{
public static void main(String[] args) {
RestTemplate template = new RestTemplate();
ProductClient productClient = RestClientProxy.createProxy("http://localhost:8080/test-server/", template, ProductClient.class);
//System.out.println(productClient.withId(123));
Random rand = new Random();
for (int i = 0; i < 10; ++i) {
Product p = new Product();
p.setName("apple");
p.setPrice(rand.nextFloat());
@ajaykumarns
ajaykumarns / ProductClient.java
Created Jun 24, 2012
Product Client interface
View ProductClient.java
@RequestMapping("/api/product/")
public interface ProductClient {
@RequestMapping(value = "/{id}", method = RequestMethod.GET)
@ResponseBody
public Product withId(@PathVariable("id") int id);
@RequestMapping(method = RequestMethod.POST)
public Product createProduct(@RequestBody Product product);
View CreateProduct.java
package com.anadathur.springapp1.example;
import org.springframework.web.client.RestTemplate;
import com.anadathur.springapp1.model.Product;
public class CreateNewProduct{
public static void main(String [] args){
RestTemplate template = new RestTemplate();
Product p = new Product();
p.setName("Apple");
p.setPrice(1.2f);
@ajaykumarns
ajaykumarns / ProductById.java
Created Jun 24, 2012
Retrieve Product by id
View ProductById.java
package com.anadathur.springapp1;
import org.springframework.web.client.RestTemplate;
import com.anadathur.springapp1.model.Product;
public class ProductById{
public static void main(String [] args){
RestTemplate template = new RestTemplate();
Product product = template.getForObject("http://kick-ass-product/api/product/{id}", Product.class, 123);
System.out.println("Product retrieved: " + product);
@ajaykumarns
ajaykumarns / Logger.java
Created Feb 20, 2012
Simple Logger in android that allows var-arg style logging
View Logger.java
import android.util.Log;
import static java.lang.String.format;
/**
* @author Ajay Kumar.N.S
* @since 1.0, 12/28/11, 11:52 PM
*/
public final class Logger {
@ajaykumarns
ajaykumarns / adb_logcat_auto_filter.py
Created Feb 20, 2012
Script to automate adb logcat
View adb_logcat_auto_filter.py
#!/usr/bin/python
import os
import subprocess as sp
import re
from sets import Set
if __name__ == '__main__':
print "Current working directory = %s" % (os.getcwd())
cmd = "find %s -name *.java -exec grep 'Logger\.forK(' '{}' \;" % os.getcwd()
suspend = 'PhoneInterfaceManager,InputDispatcher,NetlinkEvent,UsbObserver,Tethering,Finsky,battery_widget_monitor,KINETO'.split(",")