Skip to content

Instantly share code, notes, and snippets.

View lbernstein's full-sized avatar

Larry Bernstein lbernstein

View GitHub Profile
<html>
<head>
<script type="text/javascript">
// Define some global variables and initialize to blank strings
var company_name = "",
industry = "",
revenue_range = "";
<result>
<city>New York</city>
<country-name>UNITED STATES</country-name>
<fortune-1000 type="boolean">false</fortune-1000>
<forbes-2000 type="boolean">false</forbes-2000>
import java.net.URL;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.Unmarshaller;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
public class IpCaller
{
public static void main(String[] args) throws Exception
<result>
<status type="integer">404</status>
<error>Not Found</error>
</result>
public final class HTTPUtils {
private static final String HEADER_X_FORWARDED_FOR = "X-FORWARDED-FOR";
public static String remoteAddr(HttpServletRequest request) {
String remoteAddr = request.getRemoteAddr();
String x;
if ((x = request.getHeader(HEADER_X_FORWARDED_FOR)) != null) {
<html>
<head>
<script type="text/javascript">
// Define some global variables and initialize to blank strings
var company_name = "", industry = "", revenue_range = "";
//Define the callback for Demandbase IP API
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"></script>
<script>
jQuery.ajax({
url: 'http://api.demandbase.com/api/v2/ip.json?key=<Your_Demandbase_Key>',
dataType: 'json', // not 'jsonp'; this triggers CORS
//data: data, // optional params
success: function(result) {
// response handler for IP API call
industry = result.industry;
{"city":"New York","country_name":"UNITED STATES","fortune_1000":false,"forbes_2000":false,"zip":"10036",
"latitude":40.756301879883,"employee_range":"Enterprise","registry_country_name":"UNITED STATES",
"company_name":"Conde Nast Publications","demandbase_sid":1334313,"country":"US","primary_sic":2721,"annual_sales":852592000,
"registry_city":"Memphis","registry_state":"TN","registry_dma_code":640,"registry_country_code":"US",
"marketing_alias":"Conde Nast Publications","registry_company_name":"CONDENAST PUBLICATIONS",
"registry_zip_code":null,"isp":false,"street_address":"4 Times Sq","revenue_range":"$500M - $1B",
"ip":"208.92.40.133","registry_area_code":713,"phone":"212286286","web_site":"condenast.com","longitude":-73.985496520996,
"registry_country":"US","sub_industry":"Publisher","industry":"Media & Entertainment",
"employee_count":4099,"state":"NY","stock_ticker":null}
<result>
<registry-city nil="true"/>
<registry-state nil="true"/>
<registry-dma-code nil="true"/>
<registry-country-code>US</registry-country-code>
<?xml version="1.0" encoding="UTF-8"?>
<result>
<city>HOUSTON</city>
<zip>77010</zip>
<company-name>HALLIBURTON CO</company-name>
<demandbase-sid type="integer">1858829</demandbase-sid>
<primary-sic type="integer">1389</primary-sic>
<registry-city>Houston</registry-city>
<registry-state>TX</registry-state>
<registry-company-name>Halliburton Company</registry-company-name>