Skip to content

Instantly share code, notes, and snippets.

@tonetheman
tonetheman / gist:85815
Created March 26, 2009 01:33
urllib for java
import java.net.*;
import java.io.*;
class urllib {
public static StringBuffer urlopen(String url) {
try {
URL u = new URL(url);
StringBuffer sb = new StringBuffer();
BufferedReader in = new BufferedReader(
/* A facade for the Web Worker API that fakes it in case it's missing.
Good when web workers aren't supported in the browser, but it's still fast enough, so execution doesn't hang too badly (e.g. Opera 10.5).
By Stefan Wehrmeyer, licensed under MIT
*/
var WorkerFacade;
if(!!window.Worker && !iCanHasFastBrowser()){
WorkerFacade = (function(){
return function(path){
return new window.Worker(path);
<?php
$db_con = mysqli_connect("localhost", "username", "password", "database");
$result = $db_con->query('SELECT * FROM some_table');
if (!$result) die('Couldn\'t fetch records');
$num_fields = mysqli_num_fields($result);
$headers = array();
while ($fieldinfo = mysqli_fetch_field($result)) {
$headers[] = $fieldinfo->name;
}
$fp = fopen('php://output', 'w');