Skip to main content

Posts

Showing posts from August, 2011

json

Use json-lib, a library which adds JSON support to any Java program. json-lib can take a String and turn it into a JSONObject which can then be used to retrieve specific attributes. 1. Add this dependency to your project: <dependency>       <groupId> net.sf.json-lib </groupId>       <artifactId> json-lib </artifactId>       <version> 2.3 </version>       <scope> compile </scope>     </dependency> What does this mean? See How to Add a Dependency to a Java Project 2. Put the following JSON sample in your classpath: { 'foo' : 'bar' ,   'coolness' : 2.0 ,   'altitude' : 39000 ,   'pilot' :{ 'firstName' : 'Buzz' ,           'lastName' : 'Aldrin' },   'mission' : 'apollo 11' } 3. Load the resource from the classpath and parse this JSON as follows: package com . discursive . answers ; imp...

add more yum reposi

#! /bin/bash #Add repo file from Dropbox wget http://dl.dropbox.com/u/30876345/repo/dropbox.repo mv dropbox.repo /etc/yum.repos.d #Installing Dropbox yum install -y nautilus-dropbox Or; $> su - #> rpm -ivh http://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-stable.noarch.rpm #> yum install vlc #> yum install python-vlc mozilla-vlc (optionals)

spring remoting service

@Bean public FantasySportRemotingService fantasySportRemotingService() { HttpInvokerProxyFactoryBean factoryBean = new HttpInvokerProxyFactoryBean(); factoryBean.setServiceUrl(fantasySportRemotingServiceUrl); factoryBean.setServiceInterface(FantasySportRemotingService.class); if (useDigestAuthenticationForRemotingServices) { factoryBean.setHttpInvokerRequestExecutor(httpInvokerRequestExecutor()); } factoryBean.afterPropertiesSet(); FantasySportRemotingService service = (FantasySportRemotingService) factoryBean.getObject(); return service; }

Get link redirect profile

String address = "http://graph.facebook.com/hieu.trankim/picture"; URL url = new URL(address); Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress("127.0.0.1", 9666)); HttpURLConnection.setFollowRedirects(false); //Do _not_ follow redirects! HttpURLConnection connection = (HttpURLConnection) url.openConnection(proxy); String newLocation = connection.getHeaderField("Location"); System.out.println(newLocation);