Published by admin on Oct 22nd, 2007 in Uncategorized with No Comments
You can separate “memory” logically into something like four categories based on when it gets allocated and how long it lives. It’s code, static, stack and heap.
The Stack
JVM creates a private stack at the same time as the thread
(analagous to stack in C)
it holds local variables and partial results and plays a part in method invocation and return
Stack memory stores primitive types and addresses of objects
The Heap
Runtime data area from which memory for all classes and arrays is allocated
The heap is shared amoung all Java virtual machine threads
The heap has garbage collection run on it
Instance variables and objects live on the heap memory.
Local variables live on the stack memory.
Static variables live on the Static memory..
Published by admin on Oct 22nd, 2007 in Uncategorized with No Comments
First off, ensure that you can order the data. Selects do not guarantee ordering of results! This is a common mistake that breaks all kinds of things when iterating over data.
Below examples show the possible implementations to get 2nd and 3rd rows.
MySql
SQL:
-
SELECT COLUMNS FROM TABLE ORDER BY COLUMNS LIMIT 2,3
SQL Server/Sybase
SQL:
-
SELECT top 3 COLUMNS FROM TABLE ORDER BY COLUMNS
and then throw away first row.
All Others
SQL:
-
SELECT column1, column2, column3
-
FROM TABLE a
-
WHERE ( SELECT count(1)
-
FROM TABLE b
-
WHERE b.column1> a.column1 )
-
BETWEEN 2 AND 3
-
ORDER BY column1 descending
Published by admin on Oct 21st, 2007 in Uncategorized with No Comments
You can customise the creation of new unix accounts very easily: just change the /etc/skel directory.
I've just added a link for the web directory -- so that everything points to the correct locations
Published by admin on Oct 21st, 2007 in Uncategorized with No Comments
Create a .hushlogin file in your home directory!
That's all there is to it!
Published by admin on Oct 8th, 2007 in Uncategorized with No Comments
Key concepts
- Program to an interface, not an implementation.
- Use an interface to represent each behaviour.
-
Program to an inteface / supertype:
JAVA:
-
Animal animal = new Dog();
-
animal.makeSound();
Delegation Pattern:
An object outwardly expresses certain behavious but in reality delegates responsibility for implementing that behavious to an associated object in an inversion of responsibility [aka inversion of control]. The delegation pattern is the fundamental abstraction that underpins composition, mixins and aspects.
JAVA:
-
class A {
-
void f
() { System.
out.
println("A: doing f()");
}
-
void g
() { System.
out.
println("A: doing g()");
}
-
}
-
-
class C {
-
// delegation
-
A a = new A();
-
-
void f() { a.f(); }
-
void g() { a.g(); }
-
-
// normal attributes
-
X x = new X();
-
void y() { /* do stuff */ }
-
}
-
-
public class Main {
-
public static void main
(String[] args
) {
-
C c = new C();
-
c.f();
-
c.g();
-
}
-
}
Published by admin on Sep 30th, 2007 in Uncategorized with No Comments
#!/bin/sh echo "Hello world!";
Published by admin on Sep 30th, 2007 in Uncategorized with 1 Comment
Welcome to WordPress. This is your first post. Edit or delete it, then start blogging!