document.getElementById('radiusRow').style.display = ''
Wednesday, December 5, 2007
RMI lookupds using 192.168.0.3 instead of localhost
The problem was resolved by restarting XCS and is explained as follows: with RMI, the client asks uses java.naming.provider.url for a remote reference, the server responds with a server hostname and port to use to get that object. XCS was sending back its server hostname of 192.168.0.3, it hadn't updated itself since my ip changed.
From http://java.sun.com/j2se/1.4.2/docs/guide/rmi/faq.html#nethostname
For an RMI client to contact a remote RMI server, the client must first hold a reference to the server. The Naming.lookup
method call is the most common mechanism by which clients initially obtain references to remote servers. Remote references may be obtained by other means, for example: all remote method calls can return remote references. This is what Naming.lookup
does; it uses a well-known stub to make a remote method call to the rmiregistry
, which sends back the remote reference to the object requested by the lookup
method.
Every remote reference contains a server hostname and port number that allow clients to locate the VM that is serving a particular remote object. Once an RMI client has a remote reference, the client will use the hostname and port provided in the reference to open a socket connection to the remote server.
Wednesday, November 21, 2007
EJB Caching
What is a container configuration?
Dependencies
* any kind of service (eg session bean)
* config
* Transporta appconfig
Problems
* testing - dependency which requires initialization, eg. transporta appconfig
helper invokes through xcs for the appconfig
* config reads from database
* injection doesnt work for non-ejb components
* need a uniform way of handling these things
* where do you initialise things?
Solution Ideas
* dependency injection
* put all dependencies in the constructor, use interfaces
* have service locators or singletons
Dependency Injection
=====================
have an interface, and component is
injected with a working service at run time - BUT - this is troublesome if you
don't have an injection container.
alternatives to DI - new, static, Factory, JNDI
What is Spring?
Non Dependency Injection
========================
Declare dependencies in constructor, use interfaces if they need to be mocked
out. Initialization can be through JNDI container-created components, otherwise
through a setup class.
through constructors, you can make sure dependencies are met, you can easily see
what a class uses.
Links
* http://www.onjava.com/pub/a/onjava/2006/02/08/j2ee-without-application-server.html
* http://www.brandonwerner.com/category/technology/architecture/service-oriented-architecture/page/2/
* http://www.theserverside.com/tt/articles/article.tss?l=SpringFramework
Tuesday, October 9, 2007
kml, google maps
http://googlemapsbook.com/2007/01/22/extending-gmarker/
kml tutorial
http://code.google.com/apis/kml/documentation/mapsSupport.html
Thursday, September 27, 2007
Composite Entity Pattern
With a Composite Entity, a client can obtain all required information with just one remote method call.
Wednesday, September 26, 2007
Getting row with latest timestamp
http://www.sql-server-performance.com/articles/per/history_status_table_performance_p2.aspx
What if, since they should be inserted in order of time, we just did a MAX(id)?
Tuesday, September 25, 2007
javascript undefined and strict comparators
There is a difference between a variable being undefined and null. Use if(someObject) since it should evaluate both undefined and null to false.
from http://weblogs.asp.net/bleroy/archive/2005/02/15/Three-common-mistakes-in-JavaScript-_2F00_-EcmaScript.aspx
You can't overload a function.
Developers who are used to languages like Java and C# overload methods all the time. Well, in JavaScript, there are no overloads, and if you try to define one, you won't even get an error. The interpreter will just pick the latest-defined version of the function and call it. The earlier versions will just be ignored.
Undeclared variables are global.
Always, always declare your variables using the var keyword. If you don't, your variable is global. So anyone who makes the same mistake as you (or more likely, if you do the same mistake in two different places) will create nice conflicts which give rise to very difficult-to-track bugs. Even loop counters should be properly declared.
There is actually a good way to do some basic sanity checks on your script files (like multiple declarations, forgotten declarations, unassigned variables, etc.): in Firefox, go to the about:config url and look for the javascript.options.strict entry.
from http://joeyjavascript.com/2007/04/25/javascript-difference-between-null-and-undefined/
n JavaScript, undefined means a variable has been declared but has not yet been assigned a value, such as:
var TestVar;
alert(TestVar); //shows undefined
alert(typeof TestVar); //shows undefined
null is an assignment value. It can be assigned to a variable as a representation of no value:
var TestVar = null;
alert(TestVar); //shows null
alert(typeof TestVar); //shows object
From the preceding examples, it is clear that undefined and null are two distinct types: undefined is a type itself (undefined) while null is an object.
Unassigned variables are initialized by JavaScript with a default value of undefined.
JavaScript never sets a value to null. That must be done programmatically. As such, null can be a useful debugging tool. If a variable is null, it was set in the program, not by JavaScript.
null values are evaluated as follows when used in these contexts:
Boolean: false
Numeric: 0
String: “null”
undefined values are evaluated as follows when used in these contexts:
Boolean: false
Numeric: NaN
String: “undefined”
strange advanced javascript
Json is for defining a class. Not much diff btw a class and a dynamic hash.
http://www.sergiopereira.com/articles/advjs.html
Sunday, September 16, 2007
em.clear()
Saturday, September 8, 2007
Method naming conventions, ? for queries, ! for 'dangerous' methods eg. those that modify the receiver.
Specify defaults to method parameters: def cool_dude(arg1="Miles", arg2="Coltrane", arg3="Roach")
Variable length argument lists: def varargs(arg1, *rest)
Store block passed in in parameter: def initialize(name, &block)
private methods cannot be called with a "receiver"
You can return multiple things and ruby will put them into an array. You can assign these with the multi-assign thingy:
return num, square if square > 1000
num, square = meth_three
You can "explode" arrays when passing them to a method. It maps elements of the array to the parameters.
Ruby imitates keyword arguments with hashes as last parameter.
You can run OS commands by specifying them in backquotes. eg. `date`. It captures stdout.
Assignment returns back the assigned value so you can do things like File.open(name = gets.chomp)
Parallel assignment a, b = b, a
Parallel assignments and expanding arrays,
a = [1, 2, 3, 4]
b, c = a ! b == 1, c == 2
b, *c = a ! b == 1, c == [2, 3, 4]
There is also nested parallel assignment, which is a bit psycho.
words[key] ||= [] -> words[key] = words[key] || []
Case statement - you can have multiple matchers
kind = case year
when 1850..1889 then "Blues"
when 1940..1950 then "Bebop"
else "Jazz"
end
You can use while and until as "statement modifiers"
a *= 2 while a < 100
a -=10 until a < 100
Sunday, September 2, 2007
Transaction Isolation Levels
The levels are things like read commited, repeatable-read and serializable. The EJB spec doesn't define how these are set, so it's specific to the app server. Apparently you can set it if you get access to the JDBC connection, but then I assume you would have to make your whole bean BMP. There is pretty much no info on JBoss and isolation levels, except that it can be set in the datasource configuration. So perhaps you would have to create more than one datasource if you wanted more than one transaction isolation level available. Then I don't know how you would mix and match the use of these datasources with your session beans. Could you specify different entity managers and would these point to different persistence contexts and therefore not be in sync with eachother?
One article mentioned that with some appservers you can specify different isolations levels for different methods, which is ideal. Something like a transaction attribute I imagine.
Monday, August 20, 2007
Sunday, August 19, 2007
attr_writer bla
There are numerous ways to define class methods.
Make methods public, protected and public by using the keyword then any methods that come after that keyword fall under accessor.
Protected methods are accessible from the objects of the defining class and its subclasses. Private methods can only be called by the object of class that defines them. Protected access can also occur between objects of the same class. Methods are public by default.
dup method
person1 = "Jim"
person2 = person1.dup
person1[0] = 'T'
person1 -> "Tim"
person2 -> "Jim"
Freeze an object from modification using the 'freeze' method
Creating arrays
a = [1.3, "foo", 55]
a = Array.new
a[0] = "bla"
a[1] = 4
a[5] -> nil
There are all sorts of ways you can manipulate arrays, similar to perl. There are also apparently lots of methods on arrays that lets you use them as queues, stacks eg push, pop
To support chaining, return "self" (have self as last line in method).
Iterators and blocks
@songs.find {|song| title == song.name }
Blocks
- start on same line as method call after last parameter or parentheses
- variables and scope is a little complicated - if you are passed local variables from the method, the block can alter these. it can have its own locally defined variables, or also inherit the variables from surrounding code.
[1, 2].collect{ |d| d+=1 } -> [2, 3]
inject for accummulating along a list. (can leave the parameter off and it will use the first element)
[1,2,3].inject(0) { |sum, element| sum+=element }
Args pointer
class File
def File.open_and_process(*args)
f = File.open(*args)
yield f
f.close()
end
end
If File.open has an associated block, then that block will be invoked with a file object, and the file will be closed when the block terminates.
Some kernel methods:
- defined?
- Kernel.block_given?
songlist = SongList.new
class JukeboxButton < action =" action" start_button =" JukeboxButton.new(">
That code block is converted to an object of class Proc and assigned to the parameter
Associated with a block (and hence a Proc object)
is all the context in which the block was defined: the value of self and the methods,
variables, and constants in scope. Part of the magic of Ruby is that the block can still
use all this original scope information even if the environment in which it was defined
would otherwise have disappeared. In other languages, this facility is called a closure.
def n_times(thing)
return lambda {|n| thing * n }
end
p1 = n_times(23)
p1.call(3) ! 69
The method n_times returns a Proc object that references the method’s parameter,
thing. Even though that parameter is out of scope by the time the block is called, the
parameter remains accessible to the block.
Thursday, August 16, 2007
Wednesday, August 8, 2007
Monday, August 6, 2007
http://www.oracle.com/technology/pub/articles/schalk-googlemaps.html
Use decimal/numeric for storing lat long values. Apparently 5 digits after decimal gives 1 metre accuracy.
There was a project spatial-db-in-a-box or something I should look into, which shows how to use GeoTools with non-spatial databases.
SQL datatypes: http://www.sql-server-helper.com/faq/data-types-p01.aspx
Saturday, August 4, 2007
-1942.abs instead of Math.abs(-1942)Ruby notes
- String interpolation - "#{name.capitalize}"
- Global variable - $greeting
- Instance variable - @name
- Class variables - @@count
- Arrays use integers as keys, hashes can have any object as key
- convenient word array instantiation: a = %w{ ant bee cat dog elk }
- nil also means false
- you can specify the default empty return value of a hash, eg. instead of return nil when lookup fails, you can return 0 - myhash = Hash.new(0)
- Statement modifiers - convenient alternative ways of writing if and while statements if the body is just one line:
puts "Danger, Will Robinson" if radiation > 3000
square = square*square while square <>
- Regular expressions are also objects. they are built into the language
- matching: if line =~ /Perl|Python/
- line.sub(/Perl/, 'Ruby') or line.gsub(/Perl/, 'Ruby')
- one line use braces, multi-line use do, end
- pass them to methods, after all parameters
- method can run the block any number of times using the yield method
- Some people like to think of the association of a block with a method as a kind of parameter passing. This works on one level, but it isn’t really the whole story. You may be better off thinking of the block and the method as coroutines, which transfer control back and forth between themselves.
- You can provide parameters to the call to yield: these will be passed to the block.
Within the block, you list the names of the arguments to receive these parameters
between vertical bars (|). - example uses of iterators:
[ 'cat', 'dog', 'horse' ].each {|name| print name, " " }
5.times { print "*" }
3.upto(6) {|i| print i }
('a'..'e').each {|char| print char }
Classes and Objects
- initialize method is the constructor - what gets called when you do Song.new
- subclassing
class KaraokeSong < lyrics =" lyrics">
- when subclassing, ruby doesn't know which object will provide the implementation of a method until runtime - it looks for an implementation of a method in the inheritance chain starting with the child.
- shortcut for creating getters for instance variables :
class Song
attr_reader :name, :artist, :duration
end
Create setters using equals sign after method name
eg
def duration=(new_duration)
@duration = new_duration
end
then call it like this: song.duration = 33
So something like "new activity" with the aim, then a list of steps.
I can have a separate "notes" section where I put notes.
I would have a timer associated with the activity, and if I wanted, each step even. The activity would belong to the overarching task/goal
Maybe goals, and tasks associated to a goal. So goal could be "learn ruby". And task could be "setup environment".
in order not to forget tech fixes, add them as a blog
Friday, July 27, 2007
Beginnings
A good site for setting up in windows is
http://allaboutruby.wordpress.com/2006/01/09/installing-rails-on-windows-step-by-step-tutorial/
Current goals
- jquery
- javascript
- rubyrails
Labels
- bad
- caching
- classpath
- convetion
- cucumber
- cygwin
- design
- django
- eclipse
- ejb
- exceptions
- filter
- geo
- git
- gwt
- gwtt
- idioms
- ie
- integration
- issue
- ivy
- java
- javascript
- jaxb
- jboss
- jbosscache
- jdbc
- jee
- junit
- linking
- linux
- maps work
- mouse
- mvc
- netbeans
- organise
- os
- performance
- programming
- python
- rails
- regex
- rmi
- rspec
- ruby
- rubyrails
- security
- sicp
- software
- sqlserver
- syntax
- testing
- todo
- transactions
- uglycode
- vim
- web
- wifi
- ws
Blog Archive
-
▼
2007
(22)
-
►
August
(8)
- http://www.ncgia.ucsb.edu/giscc/units/u014/u014.ht...
- Attribute writersattr_writer blaThere are numerous...
- A "notebook" for each project with:blogtime tracki...
- p62Class methods and class constants:class SongLis...
- Ways ruby is superior to java:- attribute readers ...
- Mashing Google Maps with Oracle Database - shows h...
- On ruby being a genuine OO language - no static me...
- I need a way of organising a project and tasks. S...
-
►
August
(8)