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 - kanen

#1
I haven't posted in a very long time, but I thought I'd share a sneak preview of the blog I just finished, where I do mention Lisp and NewLISP when discussing AI and the Stock Market.



https://medium.com/@iamKanen/cb97aabd966d">//https://medium.com/@iamKanen/cb97aabd966d



-Kanen [fan of newLISP since 2004]
#2
newLISP in the real world / intersect bug?
August 04, 2016, 02:49:07 PM
newLISP v.10.7.0 64-bit on Linux IPv4/6 UTF-8 libffi, options: newlisp -h

> (setf a '(4 5 3 6 7))
(4 5 3 6 7)
> (setf b '(3 1 2 0 5))
(3 1 2 0 5)
> (setf c '(4 0 1 2 5))
(4 0 1 2 5)
> (setf d '(0 1 2 0 5))
(0 1 2 0 5)
> (intersect a b c d)
(5 3)
#3
newLISP newS / We are hiring newLisp programmers....
March 13, 2015, 10:24:47 AM
We are actively looking a newLisp programmer at our small network security startup -- http://www.trustpipe.com">http://www.trustpipe.com.



You can work from remote.



You need to really know newLisp and be able to write socket code, database interfaces, web connectivity and interface with C through (import) on occasion.  Knowing network security is a big plus, but not required.



We have a large, stable product which has over 10,000 lines of newLisp code and is deployed on Windows XP through Windows 8.1, Linux and Mac OS X and we are porting to new platforms this year.



Salary depends on the person and skill-set.



If you are interested, please contact me directly (do not post on this forum).  I can be reached by email through http://www.kanen.me">http://www.kanen.me



We've had some great press (here are two examples):

http://www.darkreading.com/vulnerabilities---threats/trustpipe-rolls-out-marker-based-security-technology/d/d-id/1317963">http://www.darkreading.com/vulnerabilit ... id/1317963">http://www.darkreading.com/vulnerabilities---threats/trustpipe-rolls-out-marker-based-security-technology/d/d-id/1317963

http://www.networkworld.com/article/2853977/security0/report-startup-promises-to-catch-100-of-network-attacks-with-unique-detection-technology.html">http://www.networkworld.com/article/285 ... ology.html">http://www.networkworld.com/article/2853977/security0/report-startup-promises-to-catch-100-of-network-attacks-with-unique-detection-technology.html



Lutz is an advisor to our company.



I'm happy to answer any questions.
#4
newLISP and the O.S. / OpenWRT errors with 10.6.2
March 10, 2015, 07:11:53 PM
I'm porting 10.6.2 to OpenWRT (both Intel x86 and MIPS) and I keep getting the error below with the makefile_openwrt below.



Any suggestions?


nl-filesys.c: In function 'p_spawn':
nl-filesys.c:1498:42: error: 'MAP_ANON' undeclared (first use in this function)
     PROT_READ | PROT_WRITE, MAP_SHARED | MAP_ANON, -1, 0)) == (void*)-1)
                                          ^
nl-filesys.c:1498:42: note: each undeclared identifier is reported only once for each function it appears in
nl-filesys.c: In function 'p_share':
nl-filesys.c:2152:55: error: 'MAP_ANON' undeclared (first use in this function)
     0, pagesize, PROT_READ | PROT_WRITE, MAP_SHARED | MAP_ANON, -1, 0)) == (void*)-1)
                                                       ^
make[5]: *** [nl-filesys.o] Error 1
make[4]: *** [default] Error 2
make[3]: *** [/Volumes/OpenPipe/build_dir/target-i386_i486_uClibc-0.9.33.2/newlisp-10.6.2/.configured_] Error 2
make[3]: Leaving directory `/Volumes/OpenPipe/package/devel/newlisp'
make[2]: *** [package/devel/newlisp/compile] Error 2
make[2]: Leaving directory `/Volumes/OpenPipe'
make[1]: *** [/Volumes/OpenPipe/staging_dir/target-i386_i486_uClibc-0.9.33.2/stamp/.package_compile] Error 2
make[1]: Leaving directory `/Volumes/OpenPipe'
make: *** [world] Error 2


I'm using this makefile:
# makefile for newLISP v.10.x.x on Openwrt LINUX without readline support
# I use upx to compress as hell as I can on newlisp
# Note, that readline support may require different libraries on different OSs
#

OBJS = newlisp.o         nl-liststr.o      nl-symbol.o       pcre.o  
nl-debug.o        nl-math.o         nl-utf8.o         unix-lib.o  
nl-filesys.o      nl-matrix.o       nl-web.o          win32-path.o
nl-import.o       nl-sock.o         nl-xml-json.o     win32-util.o
nl-list.o         nl-string.o       pcre-chartables.o win32dll.o

#CFLAGS = -Wall -pedantic -Wno-uninitialized -c -O2 -g -DLINUX
CFLAGS = -Wall -Wl,--gc-sections  -ffunction-sections -fdata-sections
 -c -Os  -fno-threadsafe-statics  -DLINUX -I$(TARGET_DIR)/usr/include/
 -std=gnu99
LDFLAGS = -L$(TARGET_DIR)/usr/lib/  -W1,--gc-sections -lm -ldl
CC = openwrt-linux-gcc
LD = openwrt-linux-ld


default: $(OBJS)
        $(CC) $(OBJS)  -o newlisp $(LDFLAGS)   #for openwrt
#    $(CC) $(OBJS) -g -lm -ldl -lreadline -ltermcap -o newlisp # slackware
#    $(CC) $(OBJS) -g -lm -ldl -lreadline -lncurses -o newlisp # other Linux Dist
#    $(CC) $(OBJS) -g -lm -ldl -o newlisp # without readline support
        $(STRIP) newlisp
        upx --best -o newlisp_s newlisp
        rm newlisp
        mv newlisp_s newlisp

.c.o:
        $(CC) $(CFLAGS) $<

$(OBJS): primes.h protos.h pcre.h pcre-config.h
#5
JSON understands only "false", but Lisp understands only "nil" and they are not the same.



false should translate from JSON to nil in Lisp...



Create a file called test.json:
{
"name": false,
"age": 32,
"employed": true,
"address": {
"street": "701 First Ave.",
"city": "Sunnyvale, CA 95125",
"country": "United States"
} }


(setf json_text (read-file "test.json"))
setf json_lisp (json-parse json_text))

; the result below should be (name nil) and not (name false)

(("name" false) ("age" 32) ("employed" true) ("address"
  (("street" "701 First Ave.")
   ("city" "Sunnyvale, CA 95125")
   ("country" "United States"))) )


In other words, false is not nil!
(lookup "name" json_lisp)
; false
(nil? (lookup "name" json_lisp))
; nil


From the newLisp manual:
QuoteIn newLISP, nil and true represent both the symbols and the Boolean values false and true. Depending on their context, nil and true are treated differently. The following examples use nil, but they can be applied to true by simply reversing the logic.



Evaluation of nil yields a Boolean false and is treated as such inside flow control expressions such as if, unless, while, until, and not. Likewise, evaluating true yields true.
#6
newLISP in the real world / (save) files line breaks?
November 17, 2014, 10:21:23 AM
Whenever I save a file, the line breaks are set to some strange 80 columns or similar.



I'd like lines to break more reasonably and based on (set) statements instead. Otherwise, these files have strange line-breaks and I cannot read them outside newLisp



Example:


(setf foo (rand 1000 100000))
(save "foo.lsp" 'foo)


Resulting in...


(set 'foo '(477 628 364 513 952 916 635 717 141 606 16 242 137 804 156 400 129 108
  998 218 512 839 612 296 637 524 493 972 292 771 526 769 400 891 283 352 807 919
  69 949 525 86 192 663 890 348 64 20 457 63 238 970 902 850 266 539 375 760 512
...


Why doesn't this result in:


(set 'foo '(477 628 364 513 952 916 635 717 141 606 16 242 137 804 156 400 129 108 998 218 512 839 612 296 637 524 493 972 292 771 526 769 400 891 283 352 807 919 69 949 525 86 192 663 890 348 64 20 457 63 238 970 902 850 266 539 375 760 512 ...



Is there a way to set the length of lines in a (save) file?
#7
newLISP in the real world / (silent) during runtime?
November 14, 2014, 10:38:34 AM
I'd like to run something like (exec "ls") and also have the result return to a variable, but not display to the screen at runtime.



This works;
#!/usr/bin/newlisp
(silent (setf res (exec "ls")))
(println "Exiting")
(exit)


But, this displays output to the screen:


#!/usr/bin/newlisp

(setf tarme (string "zip -r -X /tmp/foo.zip /etc/") )
(silent (exec tarme))

(println "Exiting")
(exit)


What am I missing?
#8
newLISP and the O.S. / (net-service) on Windows?
September 19, 2014, 10:34:58 AM
Is it possible to use (net-service) on Windows?



I've tried a few different ways to do this and none of them seem to work properly.



Anyone?
#9
newLISP in the real world / Syllables
September 07, 2014, 12:59:44 PM
I'm doing something which requires me to understand how many syllables are in a word I've retrieved.



Anyone have any experience figuring this out in newLisp?
#10
I'm trying to figure out if any of the items in a bigger list are in a smaller list. I've tried a bunch of options, but none of them are fast enough.


(setf big-list '( ((5 0 0 0 3 14 0 1 0 0 1 0 0 0 0 0 0) 1006) ((8 97 108 45 106 105 110 97 110 3 110 101 116 0 0 1 0 1) 1001) ((8 97 49 45 106 105 110 97 110 3 110 101 116 0 0 1 0 1) 1001) ((6 97 114 100 100 114 97 4 104 111 115 116 2 115 107 0 0 1 0 1) 1001) ((3 119 119 119 5 106 111 45 117 102 3 110 101 116 0 0 1 0 1) 1001) ((3 119 119 119 12 106 111 102 112 109 117 121 116 114 118 99 102 3 99 111 109 0 0 1 0 1) 1001) ((71 69 84 32) 1001) ((46 46 47 46 46 47 46 46 47) 232) ((205 128 232 215 255 255 255) 232) ((7 10 0 0 0 75 0 208 0) 286) ((7 0 0 0 0 75 0 208 0) 286) ((0 0 0 0 3 97 112 105 7) 1010) ))
;
(setf small-list '(59 126 1 0 0 1 0 0 0 0 0 0 3 97 112 105 7 116 119 105 116 116 101 114 3 99 111 109 0 0 1 0 1) )


Is there a REALLY FAST way to see if an item in the big-list is contained within the small-list and return the value associated with the big-list content?  For example;


> (last big-list)
((0 0 0 0 3 97 112 105 7) 1010)


I can now do something like:


(intersect ((last big-list) 0) small-list)
; (0 3 97 112 105 7)


If the above was present in the small-list (which it is in this case), I'd want to return 1010, which is the "value" of that line in the big-list.



The only problem with this way of doing it is the "0" gets squashed into one value, so I don't get a "this is an exact match". Also, intersect seems to be slower than I'd like.



Thanks!
#11
I have a list:


(set (global 'me) '(
  (80 (1010 ((84 114 117 115 116 80 105 112 101 73 115 65 119 101 115 111 109 101))) )
  (25 (1010 ((84 114 117 115 116 80 105 112 101 73 115 65 119 101 115 111 109 101))) )
  ))


I can get to it fairly easily;


(assoc 80 me)                     ; returns all "80" results
(assoc (list 80 1010) me)         ; returns all "80" + "1010" results
(last (assoc (list 80 1010) me))  ; returns the list for 80 + 1010


My question is, how do I insert a list into the results from (last (assoc (list 80 1010) me)) easily and quickly? I can get the results, insert into them, then re-insert the new list... but, I'd rather do this all-at-once.
#12
I am using the newLisp (encrypt) function to encrypt something and need to decrypt it somewhere else, in JavaScript. Then, I have to send back a response from JavaScript and decrypt it in newLisp.



My JavaScript is weak-sauce, but here's the gist (cobbled together from the Internets): https://gist.github.com/a110621fe731facb40ff">https://gist.github.com/a110621fe731facb40ff



The newLisp encrypt response looks like this:
> (setf text_enc (encrypt "My name is Earl." "foobar")
"+22O12003103O0617A7072903L"))


Whereas the JavaScript output looks like this:
> (encrypt("My name is Earl.", "foobar")
043022079012000031003079006017065055007029003076


I can make a few changes, like:
> (unpack (dup "c" (length str)) str)
(43 22 79 12 0 31 3 79 6 17 65 55 7 29 3 76)


But, I still end up with something that's not properly JavaScript-y.



If I force everything to be properly formatted for JavaScript, it all works out...
(join (map (fn (x) (format "%03d" x)) (unpack (dup "c" (length text_enc)) text_enc)) )
> "043022079012000031003079006017065055007029003076"


Until I try to go back to the format (encrypt) expects, then I'm at a loss. Because I can't just say...
> (join (map (fn (x) (pack (dup "c" 3) x)) (explode js_text 3)))
"Ѐ?0?0016 0@P`p???"


I've tried (pack "n" x) and several other options. Nothing seems to get me where I need to be.



Anyone?



P.S. Why doesn't newLisp have SHA256 or AES again? :(
#13
newLISP in the real world / SHA2 Module
December 25, 2012, 11:54:16 AM
Has anyone written an SHA2 module or function that doesn't rely on libcrypto?



I have an MD5 hash function that works, but I'm worried about collisions.



Anyone?
#14
newLISP in the real world / http Proxy Server
December 23, 2012, 12:25:23 PM
Has anyone written an http/web proxy server?



I'm playing around and want to see if I can make this work with Mozilla/Chrome/etc.



Norman? :)
#15
newLISP newS / newLisp on Android
December 20, 2012, 11:23:37 PM
We have it working. It's stable.



It is missing (semaphore), which requires libraries that do not exist on Android. I'm attaching the full source, hoping Lutz will add everything necessary to make this work as part of the main newlisp download.



Steps to compile:



1. Download the android-ndk - http://developer.android.com/tools/sdk/ndk/index.html">http://developer.android.com/tools/sdk/ndk/index.html

2. Make sure your environment works (see above documentation) on your platform

3. Unpack and put newlisp-ndk in the android-ndk directory

4. Compile newlisp



kanen (~/Code/android-ndk)$ ./ndk-build -C newlisp-ndk/
make: Entering directory `/Users/kanen/Code/android-ndk/newlisp-ndk'
Compile thumb  : newlisp <= newlisp.c
Compile thumb  : newlisp <= nl-symbol.c
Compile thumb  : newlisp <= nl-math.c
Compile thumb  : newlisp <= nl-list.c
Compile thumb  : newlisp <= nl-liststr.c
Compile thumb  : newlisp <= nl-string.c
Compile thumb  : newlisp <= nl-sock.c
Compile thumb  : newlisp <= nl-import.c
Compile thumb  : newlisp <= nl-xml.c
Compile thumb  : newlisp <= nl-web.c
Compile thumb  : newlisp <= nl-matrix.c
Compile thumb  : newlisp <= nl-debug.c
Compile thumb  : newlisp <= pcre.c
Compile thumb  : newlisp <= nl-filesys.c
Executable     : newlisp
Install        : newlisp => libs/armeabi/newlisp
make: Leaving directory `/Users/kanen/Code/android-ndk/newlisp-ndk'


The binary gets put into libs/armeabi/newlisp. From there, you just have to build an Android emulator and you can copy newLisp over to it.



For that, you need the android-sdk - http://developer.android.com/sdk/index.html">http://developer.android.com/sdk/index.html



First, list the targets and find the armeabi version you want to use. I use Target 4, which isn't the most recent, but is the most widely deployed, at API level 15.



kanen (~/Code/android-sdk/tools)$ ./android list targets
Available Android targets:
id: 4 or "Google Inc.:Google APIs:15"
     Name: Google APIs
     Type: Add-On
     Vendor: Google Inc.
     Revision: 2
     Description: Android + Google APIs
     Based on Android 4.0.3 (API level 15)
     ABIs : armeabi-v7a


Now, generate an emulator from that target platform:
kanen (~/Code/android-sdk/tools)$ ./android create avd -n MyEmulator -t 4

Then, run the emulator:
kanen (~/Code/android-sdk/tools)$ ./emulator -avd MyEmulator

Attach a shell to the emulator:
kanen (~/Code/android-sdk/platform-tools)$ ./adb shell

Make sure everything's ok and create a directory for newLisp:

# mkdir /data/nl
# chmod 777 /data/nl
# exit


Copy newLisp to the emulator:

./adb push ~/Code/android-ndk/newlisp-ndk/libs/armeabi/newlisp /data/nl


Go back into the shell and run newLisp:
kanen (~/Code/android-sdk/platform-tools)$ ./adb shell
# cd /data
# cd nl
# ls
newlisp
# ./newlisp
newLISP v.10.4.5 on Linux IPv4/6, execute 'newlisp -h' for more info.

>


Enjoy newLisp on Android. You now have a world of mobile possibilities for our favorite scripting language.


[attachment=0]newlisp-ndk.tgz[/attachment]

I've also included a link to the newLisp on arm binary, if you don't want to compile all this and just want to push newLisp to your shiny Android device: https://dl.dropbox.com/u/602830/newlisp">https://dl.dropbox.com/u/602830/newlisp
#16
newLISP in the real world / Sublime Text
November 15, 2012, 03:44:59 PM
[attachment=0]sublime_newlisp.png[/attachment]

I'm in love with Sublime Text 2. It has replaced vim, TextMate and BBEdit completely.



With the newLisp bundle & a few tweaks, it's pretty much perfect. Thanks to @curmullion for the syntax file. https://github.com/cormullion/newlisp-sublime-text-2-package">//https://github.com/cormullion/newlisp-sublime-text-2-package



http://www.nerdi.net/blog/2012/02/05/customize-your-sublime-text-2-configuration-for-awesome-coding/">//http://www.nerdi.net/blog/2012/02/05/customize-your-sublime-text-2-configuration-for-awesome-coding/



You also need this -- https://github.com/facelessuser/BracketHighlighter">//https://github.com/facelessuser/BracketHighlighter



And, you should learn a few shortcuts https://gist.github.com/1207002">//https://gist.github.com/1207002  (I'm in love with CMD+D when highlighting a word, for example -- or CMD+CTRL+G for the "whole scope").



See also:  CMD+,



(updated)
{
    "auto_complete": true,
    "close_windows_when_empty": false,
    "color_scheme": "Packages/Theme - Phoenix/Color Scheme/Tomorrow-Night.tmTheme",
    "draw_white_space": "selection",
    "find_selected_text": true,
    "fold_buttons": true,
    "font_face": "Inconsolata",
    "font_options": [ "subpixel_antialias" ],
    "font_size": 14.0,
    "highlight_line": true,
    "translate_tabs_to_spaces": true,
    "trim_trailing_white_space_on_save": true,
"save_on_focus_lost":true,
"tab_size": 2,
"folder_exclude_patterns": [".svn", ".git", ".hg", "CVS", "_build", "dist", "build", "site"]
}
#17
Anyone have this working?



If not, I'm likely going to write a module, as I need this functionality.



It looks like it's possible to query DynamoDB through an http/https standard request - http://docs.amazonwebservices.com/amazondynamodb/latest/developerguide/MakingHTTPRequests.html">//http://docs.amazonwebservices.com/amazondynamodb/latest/developerguide/MakingHTTPRequests.html. This seems similar to CouchDB, which we already have working.
#18
newLISP and the O.S. / newLisp on Android (redux)
October 17, 2012, 11:37:40 AM
I am very interested in having newLisp running on Android (especially the mobile version). Ice Cream Sandwich or higher is fine.



Anyone made this work yet?



Let me know. I'd love to collaborate and/or figure out how to make it happen.
#19
newLISP newS / Artful Code
April 30, 2012, 07:35:22 PM
As you likely already know, I'm hosting and supporting the "Artful Code" modules.



Recently, because of some security problems with github, the repository location has changed.



Please go to http://scruffythinking.com/artful">//http://ScruffyThinking.com/artful or visit the github page directly at https://github.com/kanendosei/artful-newlisp">//https://github.com/kanendosei/artful-newlisp if you are interested in the artful code modules.



If there are any bugs, problems, issues or updates, let me know.



Thanks.
#20
The title says it all.



I have a file called "foo"
foo
bar
baz
bif
doodle


> (length (parse (read-file "foo") "n"))
6
> (length (parse (read-file "foo") {n}))
1


What am I missing in this behavior?