CXG.de DDoS

| | Kommentare (2) | TrackBacks (0)

Today I've had a DDoS attack at cxg.de, our nopaste service. After doing some modifications I hope it's now over. In a few days I'll try to take cxg.de back online.

buetow.vip.tel

| | Kommentare (0) | TrackBacks (0)

I've mentioned telnic earlier and now it is possible to register a free *.vip.tel subdomain. Here is my free 3rd level domain: buetow.vip.tel. If I'll buy a buetow.tel some day, I don't know yet.

Arrays Progress

| | Kommentare (0) | TrackBacks (0)

Tonight I made the first real step in using Arrays in Fype. It is now possible to create arrays (even anonymous ones, which are used for multidimensional arrays). Here is an example:

# Create a function bar, it returns 0 by default
func bar { say "bar" }

# Create a multi dimensional array foo. Its first element is
# the return value of the func which is 0. The fourth value is a
# string "3" converted to a double number. The last element is
# an anonymous array which itself has another anonymous array
# as its last element.
my foo = [bar, 1, 4/2, double "3", ["A", ["BA", "BB"]]];

# Run on each element of foo recursively the function 'say'
say foo;

It produces the following output:
% ./fype test.fy
bar
0
1
2
3.000000
A
BA
BB

The next step will be array operations such as accessing single elements of an array or to add/remove or modify the elements.

Hello world!

In order to implement Arrays in Fype I need to have References in Fype. E.g. if I want to have multi dimensional Arrays, they should behave in contrast to Perl 5 like this:

# two-dimensional array in Perl, the programer has
# to tell explicitly to use references:
my @foo = (1, 2);
my @multi = (\@foo, [3, 4]);
print $multi[0][1]; # Prints out 2
my $bar = 'bar';
my $ref = \$bar;
print $$ref; # Prints out 'bar'

# In Fype it could look like this, all array elements
# are automatically references:
my foo = [1 2];
my multi = [foo [3 4]];
put multi[0][1]; # Prints out 2
my bar = "bar";
my ref = &bar;
put *ref; # Prints out 'bar'

As you can see, Fype will probably use & and * for the reference- and de-reference operators. Or do you have a better suggestion?

Vimperator

| | Kommentare (1) | TrackBacks (0)

I've installed the Vimperator Plugin for Fx. It makes Fx behave like Vim. It seems to be very nice. I think I ll keep it :)

vimperator.png

I recently added the "scope" function to Fype. scope can be called at any time from a Fype program. It prints all symbols which are available at the current scope to stdout.

For example if I run the following one liner:

./fype -e 'my global; func foo { my var4; func bar { my var2, var3; func baz { my var1; scope; } baz; } bar; } foo;'

Then, the output will look like this:

Scopes:
Scope stack size: 3
Global symbols:
SYM_VARIABLE: global (id=00034, line=-0001, pos=-001, type=TT_INTEGER, val=(null), ival=0, dval=0.000000, refs=-1)
SYM_FUNCTION: foo
Local symbols:
SYM_VARIABLE: var1 (id=00038, line=-0001, pos=-001, type=TT_INTEGER, val=(null), ival=0, dval=0.000000, refs=-1)
1 level(s) up:
SYM_VARIABLE: var2 (id=00036, line=-0001, pos=-001, type=TT_INTEGER, val=(null), ival=0, dval=0.000000, refs=-1)
SYM_VARIABLE: var3 (id=00037, line=-0001, pos=-001, type=TT_INTEGER, val=(null), ival=0, dval=0.000000, refs=-1)
SYM_FUNCTION: baz
2 level(s) up:
SYM_VARIABLE: var4 (id=00035, line=-0001, pos=-001, type=TT_INTEGER, val=(null), ival=0, dval=0.000000, refs=-1)
SYM_FUNCTION: bar

It backtraces all scopes at the point "scope" gets called. This helps debugging scopes in fype if needed.

PBLabs.net expires

| | Kommentare (0) | TrackBacks (0)

Today I received the following E-Mail:

The following domain name(s) will expire in 5 DAYS:

Domain Name, Expiry Date
pblabs.net, 2008-10-30

--snap--

As mentioned earlier, I am now using pb-labs.com instead of pblabs.net. Good bye .net.

Formatting C Code

| | Kommentare (0) | TrackBacks (0)
Use the following Code in your Makefile and use "make style" and get your C code formatted.  It will also prove that no  source line is longer than 80 chars. It will print a notice if more than 80 chars per line are reached and it will also print the affected filenames and line numbers. This script needs to have astyle installed and it has been tested on FreeBSD with pmake but not with GNU Make. You may need to modify the script if you are going to use Linux w/ GNU Make.

 style: astyle check
 astyle:
     find ./src -name '*.[ch]' -exec sh -c 'astyle -s3 {}; rm -f {}.orig' \;
 check:
     for f in `find ./src -name '*.[ch]'`; do awk -v f=$$f \
         '{ if (length($$0) > 80) { \
         printf "Max line length reached @ %s:%d => %d\n", \
         f, NR, length($$0) } }' $$f; done

I've played around with JConsole because I may need this at work in order to monitor running Java processes. At home I finaly found a deadlock in my diploma thesis (distributed systems simulator). I should have used JConsole earlier. It helps so much to auto detect deadlocks in threads!

Just start your Java App like this:

java -Dcom.sun.management.jmxremote -jar VS-Sim.jar

Afterwards run the JConsole with "jconsole" in the CLI and select the JVM of the Java application you want to monitor.

jconsole.png

In the "threads" tap you can watch all the threads including detect deadlocks. I found the following deadlock in VS-Sim, which seems to be a specific bug on multi core systems:

Name: Thread-2
State: BLOCKED on java.awt.Component$AWTTreeLock@1c98360 owned by:
AWT-EventQueue-0
Total blocked: 1 Total waited: 14,653

Stack trace:
java.awt.KeyboardFocusManager.clearMostRecentFocusOwner(KeyboardFocusManager.java:1777)
java.awt.Component.disable(Component.java:1286)
javax.swing.JComponent.disable(JComponent.java:3579)
java.awt.Component.enable(Component.java:1275)
java.awt.Component.setEnabled(Component.java:1238)
javax.swing.JComponent.setEnabled(JComponent.java:2647)
javax.swing.AbstractButton.setEnabled(AbstractButton.java:2064)
javax.swing.JMenuItem.setEnabled(JMenuItem.java:294)
simulator.VSSimulatorFrame.updateSimulatorMenu(Unknown Source)
- locked simulator.VSSimulatorFrame@a9ae05
simulator.VSSimulatorFrame.resetCurrentSimulator(Unknown Source)
simulator.VSSimulatorVisualization.finish(Unknown Source)
simulator.VSSimulatorVisualization.run(Unknown Source)
java.lang.Thread.run(Thread.java:619)


Name: AWT-EventQueue-0
State: BLOCKED on simulator.VSSimulatorFrame@a9ae05 owned by: Thread-2
Total blocked: 8 Total waited: 4,628

Stack trace:
java.awt.Frame.getExtendedState(Frame.java:744)
javax.swing.RepaintManager.addDirtyRegion0(RepaintManager.java:407)
javax.swing.RepaintManager.addDirtyRegion(RepaintManager.java:448)
javax.swing.JComponent.repaint(JComponent.java:4732)
java.awt.Component.repaint(Component.java:2970)
java.awt.Component.repaintParentIfNeeded(Component.java:2040)
java.awt.Component.reshape(Component.java:2028)
- locked java.awt.Component$AWTTreeLock@1c98360
javax.swing.JComponent.reshape(JComponent.java:4154)
javax.swing.JViewport.reshape(JViewport.java:854)
java.awt.Component.setBounds(Component.java:1972)
java.awt.Component.setBounds(Component.java:2109)
javax.swing.ScrollPaneLayout.layoutContainer(ScrollPaneLayout.java:869)
java.awt.Container.layout(Container.java:1432)
java.awt.Container.doLayout(Container.java:1421)
java.awt.Container.validateTree(Container.java:1519)
java.awt.Container.validate(Container.java:1491)
- locked java.awt.Component$AWTTreeLock@1c98360
javax.swing.RepaintManager.validateInvalidComponents(RepaintManager.java:635)
javax.swing.SystemEventQueueUtilities
$ComponentWorkRequest.run(SystemEventQueueUtilities.java:127)
java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
java.awt.EventQueue.dispatchEvent(EventQueue.java:597)
java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:273)
java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:183)
java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:173)
java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:168)
java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:160)
java.awt.EventDispatchThread.run(EventDispatchThread.java:121)

Synonyms in Fype

| | Kommentare (0) | TrackBacks (0)

I've implemented synonyms for Fype.

Each variable can have as many synonyms as wished. A synonym is another name to access the content of a specific variable. Here is an example of how to use synomyms:

my foo = "foo";
my bar = \foo;
foo = "bar";

# The synonym variable should now also set to "bar"
assert "bar" == bar;

Synonyms can be used for all kind of identifiers. It's not limited to normal variables but can be also used for function and procedure names etc. Here is yet another example:

# Create a new procedure baz
proc baz { say "I am baz"; }

# Make a synonym baz, and undefine baz
my bay = \baz;
undef baz;

# bay still has a reference of the original procedure baz
bay; # this prints aut "I am baz"

assert 0 == defined baz;
assert 1 == defined bay;

# This removes the procedure from memory
undef bay;