Skip to content

Instantly share code, notes, and snippets.

@tedheich
tedheich / build.xml
Created November 22, 2009 13:19
Basic ant build file
<?xml version="1.0"?>
<project name="Your Project Name" default="compile" basedir=".">
<property name="src" value="src"/>
<property name="lib" value="lib"/>
<property name="build" value="build"/>
<path id="classpath.base">
<pathelement location=""/>
<pathelement location=""/>
@tedheich
tedheich / snippet-httpd.conf
Created November 22, 2009 10:39
Snippet of /etc/apache2.httpd.conf in Snow Leopard
LoadModule dav_module libexec/apache2/mod_dav.so
LoadModule status_module libexec/apache2/mod_status.so
LoadModule autoindex_module libexec/apache2/mod_autoindex.so
LoadModule asis_module libexec/apache2/mod_asis.so
LoadModule info_module libexec/apache2/mod_info.so
LoadModule cgi_module libexec/apache2/mod_cgi.so
LoadModule dav_fs_module libexec/apache2/mod_dav_fs.so
LoadModule vhost_alias_module libexec/apache2/mod_vhost_alias.so
LoadModule negotiation_module libexec/apache2/mod_negotiation.so
LoadModule dir_module libexec/apache2/mod_dir.so
class Diagnostics {
public static void main(String []args) {
System.out.println("JAVA CLASSPATH = " + System.getProperty("java.class.path"));
System.out.println("LIBRARY PATH = " + System.getProperty("java.library.path"));
System.out.println("EXT DIRS = " + System.getProperty("java.ext.dirs"));
System.out.println("PATH SEPARATOR = " + System.getProperty("java.path.separator"));
}
}
@tedheich
tedheich / DoubleEqualTest.java
Created November 19, 2009 08:36
double equal versus equal method
public class DoubleEqualTest {
public static void main(String []args) {
Integer a = new Integer(1024);
Integer b = new Integer(1024);
boolean test = a < b || a == b || a > b;
if (test) System.out.println("this won't happen");
}
@tedheich
tedheich / KnowType.java
Created November 19, 2009 01:13
How to find out the class of the object
class Shape {}
class Circle extends Shape {}
class Square extends Shape {}
class KnowType {
public static void main(String []args) {
Shape s = new Shape();
Circle c = new Circle();
Square sq = new Square();
@tedheich
tedheich / ArrayEx.java
Created November 18, 2009 12:11
Array examples for creating Java Objects
class ArrayEx {
public static void main(String []args) {
Object obj[] = new Object[3];
for (int i=0;i < obj.length; i++ ) {
if (obj[i] instanceof Object) {
System.out.println("obj[" + i + "] = Object" );
}
@tedheich
tedheich / IncDec.java
Created November 18, 2009 08:06
Shows the effect of postfix and prefix increment operator in Java
class IncDec {
public static void main(String []args){
int a = 0;
int b = 0;
int x = a++;
int y = ++b;
System.out.println("Value of a = " + x);
System.out.println("value of b = " + y);
}
@tedheich
tedheich / samba.conf
Created November 17, 2009 14:22
Simple samba configuration file
security=user
username map=/etc/samba/smbusers
[homes]
comment=Home Directories
browseable=yes
writable=yes
valid=%S ; so that only the defined users can view it
@tedheich
tedheich / simple squid.conf
Created November 17, 2009 14:09
Simple squid.conf
visible_hostname thismachine.mylan.com
cache_effective_user squid squid
http_port 192.168.1.2:3128
acl localnet src 192.168.1.0/24
http_access allow localnet
debug_options ALL,1
@tedheich
tedheich / readline.py
Created November 15, 2009 10:52
Process a file line by line in Python
import sys
for line in open(sys.argv[1],'r'):
print line