Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Topics - newdep

#41
newLISP newS / newlisp.org offline
July 09, 2009, 02:39:54 PM
Hi Lutz,



are you working on the main page?

Getting error on newlisp.org ..cgi error...



Norman
#42
Whither newLISP? / newlisp and the C++ revolution
July 08, 2009, 01:40:57 PM
It seems that more and more library's are moving towards c++

This hasnt been always the case. I know some pretty nice languages

that where c library based and also Gui's and other applications..



Somehow it all slightly is moving towards c++ and being a newlisp user

im wondering how to overcome the fact that newlisp cant keep up with

binding to library's.



Im far from a c++ programmer so i dont know the details but there

must be a way to interact with c++ library's somehow.. and it is

discussed befor here but not deep enough!



This topic is realy eating me as I have some nice projects on the stack

that get dusty because im not willing to learn c++ but want a binding

to a highlevel language..



Is there a way to adjust or add-on something/somehow to newlisp to

make c++ library binding happen...

Not only for mysake but for the sake of newlisp's future perhpas..



Just a mind storm that keeps me awake...
#43
The N810 is a Nokia Internet Tablet based on http://www.maemo.org">//http://www.maemo.org linux using the TI processor which is ARM based.

(N810 has a 400 MHz TI OMAP 2420 Cpu)



With the scratchbox setup on a linux PC you can cross-compile X86-ARM/EL.



If I did it all correct then newLisp v 10.0.0 was successfuly compiled for the ARM/EL, actualy out of the box without errors on the Diablo release of

maemo. Now this compilation was so very easy Im not sure it its correct ..hahaha.. But it sure does run ;-)



Now the real testing needs to be done, end of this week probably...



Here the output of the execution from within a scratchbox chrooted shell.

(a debian Arm version inside my slackware 12.2 environment with X11 client (xephyr) that emmulates the maemo GUI)


[sbox-DIABLO_ARMEL: ~/newlisp-10.0.0] > ldd newlisp
        libm.so.6 => /lib/libm.so.6 (0x00000000)
        libdl.so.2 => /lib/libdl.so.2 (0x00000000)
        libc.so.6 => /lib/libc.so.6 (0x00000000)
        /lib/ld-linux.so.3 => /lib/ld-linux.so.3 (0x00000000)

[sbox-DIABLO_ARMEL: ~/newlisp-10.0.0] > file newlisp
newlisp: ELF 32-bit LSB executable, ARM, version 1 (SYSV), for GNU/Linux 2.6.8, dynamically linked (uses shared libs), stripped

[sbox-DIABLO_ARMEL: ~/newlisp-10.0.0] > ls -al newlisp
-rwxrwxr-x  1 user users 232248 Jun 15 17:03 newlisp

[sbox-DIABLO_ARMEL: ~/newlisp-10.0.0] > ./newlisp
newLISP v.10.0.0 on Linux IPv4, execute 'newlisp -h' for more info.

> (sys-info)
(379 268435456 368 1 0 2048 31054 10000 1)
>


So actualy newlisp is now able to run on the ARM/EL based handheld

devices...Finaly I have newLisp in my handpalm ;-)



To be continued...
#44
Quote
;; Auto proxy discovery from network

;; straight grep from wpat.dat file

;; and set newlisp proxy

;; assumes host.domain

;;

(env "HTTP_PROXY"

 (and

  (regex "PROXY (.*); "

   (get-url

    (append "http://wpad">http://wpad."

     (join (-2 (parse (net-lookup (net-interface)) "." )) ".") "/wpad.dat")))

      (string "http://" $1)))
#45
Do these without the manual and without the prompt ;-)



first 5 Riddles..



(1) What function sets all its symbols to their associated values?

(2) Name an eatable newlisp function

(3) Does this function return 'true or 'nil? ((fn(x)) true)

(4) How many buildin functions does newlisp have?

(5) Returns (cons '(nil) '(nil)) visualy the same as (dup (array 1) 2)?



Enjoy ;-)
#46
This script check on specific IO content inside a script.

If you want a quick overview on the scripts used newlisp functions.

I mainly use it to quickly check what the script contains on

IO functions or systems functions befor executing it with a

load read-file or.....Its though a visual check.. If its a small

script you may not even need this checkup..



Usage:



$check.lsp "http://www.nodep.nl/downloads/newlisp/update.lsp">http://www.nodep.nl/downloads/newlisp/update.lsp"

$check ./strange.lsp





#!/usr/bin/newlisp -n
# start newlisp with no init.lsp

# quick check a script!
# newlisp v10+
# This script checks the level of 'use of IO functions'
#

(setq net '( "delete-url" "get-url" "net-accept" "net-close" "net-connect" "net-error" "net-eval"
"net-interface" "net-listen" "net-local" "net-lookup" "net-peek" "net-peer" "net-ping"
"net-receive" "net-receive-from" "net-receive-udp" "net-select" "net-send" "net-send-to"
"net-send-udp" "net-service" "net-sessions" "post-url" "put-url"))

(setq dev '( "!" "append-file" "change-dir" "close" "command-event" "copy-file" "delete-file" "device"
"directory" "encrypt" "exec" "file-info" "load" "make-dir" "open" "peek" "prompt-event" "read-buffer"
"read-char" "read-file" "read-key" "read-line" "real-path" "remove-dir" "rename-file" "save"
"search" "seek" "source" "write-buffer" "write-char" "write-file" "write-line"))

(setq mem '( "cpymem" "address" "get-char" "get-float" "get-int" "get-long" "get-string" "import"
"abort" "destroy" "exec" "fork" "pipe" "process" "semaphore" "share" "spawn" "sync" "wait-pid"))

(setq FILE (parse (read-file (last (main-args)))))

(define (tab x y)
 (println x (dup " " (- 20 (length x))) y ))

(map (fn(x) (if (> x 0) (tab (net $idx) x))) (count net (intersect FILE net true)))
(map (fn(x) (if (> x 0) (tab (dev $idx) x))) (count dev (intersect FILE dev true)))
(map (fn(x) (if (> x 0) (tab (mem $idx) x))) (count mem (intersect FILE mem true)))

(exit)

#47
newLISP in the real world / self-destruct
April 07, 2009, 03:51:00 AM
As the oposite of creating macro's from macro's or functions from

funtions I wanted something that deleted itself after execution..



Sound logical indeed but correct me if im wrong but in previous

releases of newlisp you couldn't destroy yourself as being a variable

or function...



Seems that indeed now the destructive-save function 'copy is introduced

you can destroy yourself (finaly!..who doesnt want that ;-)



*edited* seems that for functions the 'copy isnt needed only

the 'catch is enough





there is

(MAIN)-> (setq self-destruct (copy (delete 'self-destruct)))
true
(MAIN)-> self-destruct
nil


And



(MAIN)-> (define self-destruct (catch (copy (delete 'self-destruct))))
?
(MAIN)-> self-destruct
nil


And there is

(MAIN)-> (define (self-destruct) (catch (copy (delete 'self-destruct))))
(lambda () (catch (copy (delete 'self-destruct))))
(MAIN)-> (self-destruct)
true
(MAIN)-> (self-destruct)
ERR: invalid function : (self-destruct)
(MAIN)-> self-destruct
nil




And namespaced

(MAIN)-> (define (self:destruct) (catch (copy (delete 'self:destruct))))
(lambda () (catch (copy (delete 'self:destruct))))
(MAIN)-> (self:destruct)
true






What surprices me is that 'Catch indeed catches here the error, because if you dont the function will crash newlisp..



The '?' is probably a tiny bug? Or is it indeed a BIG Question to newlisp ;-)
#48
Well Eastern is upcoming and for those who know the drill its time to hide and seek eggs.. Well at least in reallife..

But then you also have the kind of eggs hidden in programs..




(define-macro (eastern)
 (let (egg "TRUCBANKAw4LAEdFDRMTFV1IShAQEkkJCgMCFUkJCUgDChAJCQgGARRICwIQCQ4UFUgVBAUFDBNJER8TR04=")
  (println (eval-string (encrypt (base64-dec egg) (args 0))))))


Enjoy ;-)
#49
Lutz,



(MAIN)-> (net-connect "localhost" 23)

nil

(MAIN)-> (net-error)

(4 "ERR: Connection failed")

(MAIN)-> (sys-error)

(111 "Connection refused")





The example shows (111 "Connection refused"),does this mean that

all errors from the "net-..." functions are always covert by  (sys-error?)



last but not least.. Im unable to get the (error-event) to work on

linux... Is it correct that when having an event-handler running it will

automaticly throw the error and execute its function? Or should I explicitly

call for the return value? (i didnt think so though...) Anyway the example

from the manual doesnt work here..
#50

#!/usr/bin/newlisp
;;
;; Forward-Only Ftp.
;; v0.1 premature alpha release by - nodep (c)opyleftathome -
;; hacked this script because I needed to move very big files
;; between 2 systems where I didnt had any shell access but only
;; ftp access. (yeah handy but it happens far too often ;-)
;;
;; ---
;; If you have to move very big files between 2 machines and only have
;; ftp access to them then you always have to store the file
;; on your local machine first befor forwarding to the other. (ugly!)
;;
;; And if your machine hasn't enough diskspace (lucky you) then
;; the only way to move the files between the machines is via
;; a network-forward via your machine.
;;
;; This tool connects ftp-server #1 and #2 (source & destination).
;; Your machine that runs this script is the forwarder
;; (No storing of data, forward only).
;;
;; Partly borrowed some ftp data from the newlisp ftp.lsp module.
;;
;; Runs Passive mode only
;; Buffer size 8192 bytes
;; Tested on Unix and NAS systems only
;; Script might not run on all ftp servers.
;; Windows users might need to change the read-key "n" into "r"
;; ---
;;


(define (net-ret str code)
    (net-send S str)
    (net-receive S B 256 "rn")
    (println B)
    (if (starts-with B code) B))

(define (net-init user pass host dir)
    (if (setq S (net-connect host 21))
        (net-receive S B 256 "rn") (exit 1))
    (net-ret (append "USER " user "rn") "331")
    (net-ret (append "PASS " pass "rn") "230")
    (net-ret (append "CWD "  dir  "rn") "250")
    (net-ret "TYPE Irn"                 "200")
    (net-ret "PASVrn"                   "227")
    (regex {(d+),(d+),(d+),(d+),(d+),(d+)} B)
    (list S (string $1 "." $2 "." $3 "." $4)
            (+ (* 256 (int $5)) (int $6))) )

(define (net-go)

    (setq in  (net-init src-user src-pass src-host src-dir))
    (setq pin (net-connect (in 1) (in 2)))

    (setq out  (net-init des-user des-pass des-host des-dir))
    (setq pout (net-connect (out 1) (out 2)))

    (net-send (in 0)  (append "RETR " src-file "rn"))
    (setq S (in 0))
    (net-ret "STATrn" "150")

    (net-send (out 0) (append "STOR " des-file "rn"))
    (setq S (out 0))
    (net-ret "STATrn" "150")

    (while (net-receive pin buffer 8192)
       (and (print ".") (net-send pout buffer 8192)))

    (net-close pin)
    (net-send (in 0) "QUITrn")
    (net-close (in 0))

    ;; wait for full flush this is a guessed time.
    ;; needed when data is buffered somewhere.
    (sleep 3000)

    (net-close pout)
    (net-send (out 0) "QUITrn")
    (net-close (out 0))

    (println "Done.")
)


;;; user input section

(println (dup "-" 70))
(println "* Forward only FTP v0.1")
(println (dup "-" 70))
(print "Source FTP Server: ")
(setq src-host (read-line))
(print "Source Username  : ")
(setq src-user (read-line))
(print "Source Password  : " )
  (while (!= (format "%c" (setq c (read-key))) "n")
    (push (format "%c" c) src-pass -1) (print "*"))
(setq src-pass (join src-pass))
(println)
(print "Source Directory : ")
(setq src-dir (read-line))
(print "Source File      : ")
(setq src-file (read-line))

(println (dup "-" 70))
(print "Destination FTP Server: ")
(setq des-host (read-line))
(print "Destination Username  : ")
(setq des-user (read-line))
(print "Destination Password  : " )
  (while (!= (format "%c" (setq c (read-key))) "n")
    (push (format "%c" c) des-pass -1) (print "*"))
(setq des-pass (join des-pass))
(println)
(print "Destination Directory : ")
(setq des-dir (read-line))
(print "Destination File      : ")
(setq des-file (read-line))
(println (dup "-" 70))

;; run
(net-go)
(exit)





(load "http://www.nodep.nl/downloads/newlisp/fftp.lsp">//http://www.nodep.nl/downloads/newlisp/fftp.lsp")
#51
http://www.bernardbelanger.com/computing/NaDa/index.php">http://www.bernardbelanger.com/computing/NaDa/index.php
#52
Hi Lutz,



I guess the RIPEMD160 can be added too to the crypto.lsp..

not that difficult to add (actualy the same as sha1 ;-) but ripemd160 is sometimes used instead of md5, just handy to have..



I only tested it on Win32 with GnuWin32 but i assume itll run unix too,

can check it later today..



I cant find the SHA256 inside the openssl lib actualy, did you had a look at

that perhpas?









(import library "RIPEMD160")
...
...
...


;; @syntax (crypto:ripemd160 <string> <bool-raw>)
;; @param <string> The string buffer for which to calculate a RIPEMD160 hash
;; @param <bool-raw> Return the raw binay buffer when 'true'.
;; @return The 20 Byte RIPEMD160 hash as a 40 Byte long hex string or as a 20 byte binary buffer.
;; @example
;; (crypto:ripemd160 "ABC") => "df62d400e51d3582d53c2d89cfeb6e10d32a3ca6"
;;
;; (crypto:ripemd160 (read-file "newlisp.exe")) => "9c1185a5c5e9fc54612808977ee8f548b2258d31"

(define (ripemd160 str raw-flag)
(if raw-flag
(let (buff (dup "00" 20))
(cpymem (RIPEMD160 str (length str) 0) buff 20)
buff)
(join
    (map (lambda (x) (format "%02x" (& x 0xff)))
(unpack (dup "c" 20) (RIPEMD160 str (length str) 0)))
)
)
)
#53
Whither newLISP? / Does newlisp know...?
March 25, 2009, 02:25:05 PM
It spins now a few days through my head

"how to let newlisp know that the code it is about to execute is newlisp code"



So actualy Befor executing 'any' script, newlisp itself needs to check the content of the script if its pure newlisp.



There are some ways to do this and Im fiddling with the mapping

of (symbols) against the code to read.. but it must be tiny..



Any idea's that might return faster and small code results are welcome ;-)
#54
newLISP in the real world / <updated> update.lsp
March 25, 2009, 09:15:00 AM
(load "http://www.nodep.nl/downloads/newlisp/update.lsp">//http://www.nodep.nl/downloads/newlisp/update.lsp")

has been updated ..had a real big bugger in it..



+ v1.12 newlisp Updater (Linux)

+ Running version => 10000

+ Found version   => 10003

+ Retrieving file => newlisp-10.0.3.tgz (1440807 Bytes)

+ Download speed  => 125276 Bps

+ Writing file    => /tmp/newlisp-10.0.3.tgz

+ Done...





enjoy...



PS: works on all os versions, though there is yet only differentiation

between OSX WIN and UNIX..
#55
Hi Lutz,



Is there way to Pre-determine what memory address newlisp will

use when using get-url read-file load ..etc. (all functions that

load into memory directly)



Im trying to create a callback to inspect loaded data but I cant

find a proper way to do so.. It always endsups doing it after the

data was fully read..





Would be nice to have a function like "inspect" that returns the

data-segment for a specific function in combination with address ..etc..



Not sure if its possible but it would open another door in newlisp ;-)



Norman.
#56
newLISP in the real world / qa-dot & qa-comma
January 07, 2009, 12:33:44 PM
Lutz,



I always thought that qa-dot and qa-comma gave output on what

was tested.. I now only see results but cant see where its failing..



I cant find any swicth related to debugging..or is there?



Norman.
#57
newLISP newS / http://www.osnews.com/ looks at newlisp
January 05, 2009, 03:16:39 PM
http://www.osnews.com/">//http://www.osnews.com/



http://www.osnews.com/story/20728/A_Look_at_newLISP">//http://www.osnews.com/story/20728/A_Look_at_newLISP
#58
newLISP in the real world / mind spin with 'let ?
December 09, 2008, 03:07:43 PM
Lutz,



is it correct that 'inc is always working on globals ?





(MAIN)-> (delete 'a)

true

(MAIN)-> (let (a 1) (+ a 1))

2

(MAIN)-> a

nil

(MAIN)-> (delete 'a)

true

(MAIN)-> (let (a (inc a)))

nil

(MAIN)-> a

1



a is 1 ?? i dont get it actualy...
#59
Anything else we might add? / replace regular expressions
December 07, 2008, 01:22:26 AM
..Finaly A good statement from larry Perl Wall  regarding P6  ->



"It will break backward compatibility [but] in order to simplify it we have to get rid of old cruft, particularly the regular expression cruft," Wall said. "A lot of the unreadability of Perl is related to the regular expression syntax – and we didn't do that, we got it from Unix. It needs to be end-of-lifed. Regular expressions are not strings, they are a sub-language. We took it and made it worse. There is this two-pass nature that is evil."

http://www.computerworld.com.au/article/269758/perl_6_break_compatibility_support_other_interpreters?eid=-6787">//http://www.computerworld.com.au/article/269758/perl_6_break_compatibility_support_other_interpreters?eid=-6787



...Now... Rebol already did build its own very readable parsing dialect, the most Elegant dialect I know of...



Now the question rises? can newlisp come back (because we had some functions in the past) with a readable string language instead of regex?

I often though about this but i never came to to point on setting something up.... One thing is sure... regex (those ugly ants) is not enhancing a language its making it flexible but not readable..



Regex is flexible, no doubt, but when wanting to do a simple multiple

string reach replacement (something that is 99% the case) I would

like to see no regex at all ;-) Yes we get used in using it but its time for

readablility..secondly regex's dont fit into Lisp..



I vote for an alternative ;-)
#60
Anything else we might add? / (apply 'off 'topic)
November 29, 2008, 01:39:08 PM
For those who like illusions...http://www.electricsheep.org/">//http://www.electricsheep.org/



meanwhile  

http://www.youtube.com/watch?v=KCy928QJCDE&feature=related">//http://www.youtube.com/watch?v=KCy928QJCDE&feature=related