Monday, November 30, 2015

CouchDB, couchjs, SpiderMonkey, brew and Xcode

I have tried to play with couchjs, the CouchDB 'js engine' today. It involved some troubles (as always) so they are 'saved' here:
$sw_vers
ProductName: Mac OS X
ProductVersion: 10.11.1
BuildVersion: 15B42

$xcodebuild -version
Xcode 5.0.1
Build version 5A2053



# Installing XCode from app store (downloading 4.3 GB) ;-(

$ xcodebuild -version
Xcode 7.1.1
Build version 7B1005


# paranoid

brew --version
0.9.5 (git revision fe22f; last commit 2015-09-21)

# no so
brew --version
0.9.5 (git revision 6fe85; last commit 2015-11-30)

# and now ?
brew install spidermonkey

# yes:
/usr/local/Cellar/spidermonkey/1.8.5_1/bin/js
js> Object.keys({});
[]

Yes Yes Yes, this was my main purpose to do this:
/Applications/Apache\ CouchDB.app/Contents/Resources/couchdbx-core/lib/couchdb/bin/couchjs
Usage: couchjs [FILE]

The couchjs command runs the Apache CouchDB JavaScript interpreter.

The exit status is 0 for success or 1 for failure.

Options:

  -h          display a short help message and exit
  -V          display version information and exit
  -H          enable couchjs cURL bindings (only avaiable
              if package was built with cURL available)
  -S SIZE     specify that the runtime should allow at
              most SIZE bytes of memory to be allocated
  -u FILE     path to a .uri file containing the address
              (or addresses) of one or more servers

Report bugs at .

Wednesday, September 30, 2015

I gave up (StackOverflow)

This has been a long time ignored resource for me. Since today I have started to contribute under my account ;-((

Monday, September 28, 2015

CSS colors

Mission: extract all CSS colours from file:
analyze-css --file my.css | jsontool offenders.colors | jsontool -a | cut -d" " -f1
TODO: better ways (recursive)? TODO: extract all colours from the page (runtime) 'snipped or bookmarklet wanted'

Tuesday, September 1, 2015

Guitar patches by effect pedal


curl http://guitarpatches.com/units.php |\
grep -B1 "Patches:" | sed "s;.*>\(.*\)<.*;\1;" |\
grep -v "^--" | paste -s -d $'\t\n' - |\
sort -t$'\t' -k2nr

G2 and G2.1u 1363
G1 and G1x 944
G3 and G3X 590
G2Nu and G2.1Nu 492
GT-8 461
GT-10 409
RP50 and RP80 405
G1N and G1XN 385
G5 384
ME-70 327
RP150 321
AX3G and AX5G 299
RP70 and RP90 215
G-Major 156
ME-25 148
G1on and G1Xon 144
AX3000G 139
B2 and B2.1u 135
PX4 117
GT-100 93
THR10 84
ME-20 71
ME-50 67
Guitar Rig 5 Pro 56
A2 and A2.1u 54
RP500 49
MS-50G 45
Guitar Rig 3 36
ME-80 32
G7.1UT 31
B3 29
GT-100v2 & GT-001 29
Tonelab SE 29
THR10X 28
G1U 26
ToneLab LE 26
B1 and B1x 24
G9.2TT 22
GT-10B 22
THR10C 22
505II and 606 20
PX5D 17
BlackBox 14
G-DEC 3 11
Mustang I & II 11
X3, X3 Live and X3 Pro 11
AX3B and AX5B 10
ME-20B 10
GSP1101 9
GT-6B 8
RP155 8
GR-55 7
ME-30 7
V-AMP 2 7
THR5 6
ME-50B 5
Pocket POD Express 5
AX3000B 4
HD500 4
RP300A 4
B9.1ut 3
GR-1 3
GT-Pro 3
Mustang III, IV & V 3
RP1000 3
RP360 & RP360 XP 3
StompLab IG/IIG 3
ZFX plug-in 3
BP355 2
G-Major 2 2
GP-10 2
HD400 2
V-AMP 3 2
2120 VGS 1
Axe-FX Standard/Ultra 1
Axe-Fx II 1
Element & Element XP 1
Eleven Rack 1
HD300 1
Pandora Mini/Stomp 1
RP355 1
Spider IV 75, 120, 150 & HD150 1
THR5A 1
ToneLab EX 1
ToneLab ST 1

Thursday, March 26, 2015

CLI BROKEN - Oracle SQL Developer 4.0.3 (4.0.3.16.84)

Tools without CLI is useless. Today I wanted to test formatting features of SQL Developer from command line as part of my git diff pipeline. So far ?

It seems pretty unusable, this is script:

/Applications/SQLDeveloper.app/Contents/Resources/sqldeveloper/sqlcli

#!/bin/bash
CP=jdbc/lib/ojdbc6.jar
CP=${CP}:jlib/orai18n-collation.jar
CP=${CP}:jlib/orai18n-mapping.jar
CP=${CP}:jlib/orai18n-servlet.jar
CP=${CP}:jlib/orai18n-utility.jar
CP=${CP}:jlib/orai18n.jar
CP=${CP}:sqldeveloper/extensions/oracle.sqldeveloper.jar
CP=${CP}:sqldeveloper/lib/oracle.sqldeveloper.utils.jar
CP=${CP}:sqldeveloper/lib/oracle.sqldeveloper.utils-nodeps.jar
CP=${CP}:sqldeveloper/lib/itextpdf-5.1.2.jar
CP=${CP}:sqldeveloper/lib/poi-3.7-20101029.jar
CP=${CP}:modules/oracle.javatools_11.1.1/javatools-nodeps.jar
CP=${CP}:sqldeveloper/lib/jline-0.9.9.jar
CP=${CP}:ide/lib/javatools.jar
CP=${CP}:ide/extensions/oracle.ide.jar
CP=${CP}:jlib/jdev-cm.jar
CP=${CP}:ide/lib/dbapi.jar

#java -cp ${CP} oracle.dbtools.raptor.newscriptrunner.commands.SQLCli $*

java -cp ${CP} oracle.dbtools.raptor.scriptrunner.utils.SqlCli $*

checking this for existence of specified jars with simple oneliner:

ls -1 $(tr ":" "\n" <<< "$CP")

Raises 5 nonexisting paths !!!:

ls: jlib/jdev-cm.jar: No such file or directory
ls: modules/oracle.javatools_11.1.1/javatools-nodeps.jar: No such file or directory
ls: sqldeveloper/lib/itextpdf-5.1.2.jar: No such file or directory
ls: sqldeveloper/lib/oracle.sqldeveloper.utils.jar: No such file or directory
ls: sqldeveloper/lib/poi-3.7-20101029.jar: No such file or directory

Thank you oracle for not-testing such simple things.

Monday, January 5, 2015

npm test (a sample case study of selected libraries)

What are people using as 'Test a package' script for their node packages ? I have taken several node modules from my test project and searched for scripts.test in their package.json.

Here is complete listing of script.test values from package.json files:

assert-plus
aws-sign2
bindings
byline
cli
combined-stream
core-util-is
cssom
ctype
delayed-stream
difflib
domelementtype
forever-agent
heap
inherits
jshint
json-diff.bin
mime
nan
node-uuid
nwmatcher
tunnel-agent
xml2js
xmlhttprequest
xpath
dreamopt             ./node_modules/.bin/mocha
json-diff            ./node_modules/mocha/bin/mocha
json-diff-patch      echo Error: no test specified && exit 1
wordwrap             expresso
when                 jshint . && buster-test -e node && promises-aplus-tests test/promises-aplus-adapter.js
json                 make test
printf               make test
qs                   make test
boom                 make test-cov
cryptiles            make test-cov
hawk                 make test-cov
hoek                 make test-cov
sntp                 make test-cov
entities             mocha && npm run lint
htmlparser2          mocha && npm run lint
domhandler           mocha -R list && jshint index.js test/
domutils             mocha test/tests/**.js && jshint index.js test/**/*.js lib/*.js
cli-color            node ./node_modules/tad/bin/tad lib
es5-ext              node ./node_modules/tad/bin/tad lib
jsdom                node ./test/runner
inherits             node test
marked               node test
json-stringify-safe  node test.js
oauth-sign           node test.js
sax                  node test/index.js
combined-stream      node test/run.js
form-data            node test/run.js
request              node tests/run.js
punycode             node tests/tests.js
open                 node_modules/mocha/bin/mocha
contextify           nodeunit test/
async                nodeunit test/test-async.js
cssstyle             nodeunit tests
xmldom               proof platform win32 && proof test */*/*.t.js || t/test
JSONStream           set -e; for t in test/*.js; do echo '***'  '***'; node ; done
through              set -e; for t in test/*.js; do node ; done
asn1                 tap ./tst
lru-cache            tap test
minimatch            tap test
glob                 tap test/*.js
graceful-fs          tap test/*.js
isarray              tap test/*.js
jsonparse            tap test/*.js
sigmund              tap test/*.js
readable-stream      tap test/simple/*.js
string_decoder       tap test/simple/*.js
http-signature       tap tst/*.js
tough-cookie         vows test.js

No test specified

25 modules have no test specified. It means they have no test or if they have it, you must read the manual how to run it.

tap (Test Anything Protocol tools for node)

11 modules uses tap.

mocha

7 modules uses mocha as their test runner. Also here are differencies, some people rely on global mocha installed, some use local node module.

dreamopt             ./node_modules/.bin/mocha
json-diff            ./node_modules/mocha/bin/mocha
entities             mocha && npm run lint
htmlparser2          mocha && npm run lint
domhandler           mocha -R list && jshint index.js test/
domutils             mocha test/tests/**.js && jshint index.js test/**/*.js lib/*.js
open                 node_modules/mocha/bin/mocha

make

8 uses make

vows

1 uses vows - Asynchronous BDD & continuous integration for node.js

Linting as part of test process

5 uses linting as part of their test process, some more can be hidden in make files (TODO:)

when                 jshint . && buster-test -e node && promises-aplus-tests test/promises-aplus-adapter.js
entities             mocha && npm run lint
htmlparser2          mocha && npm run lint
domhandler           mocha -R list && jshint index.js test/
domutils             mocha test/tests/**.js && jshint index.js test/**/*.js lib/*.js

npm run lint and scripts.lint

Some projects also use scrpts.lint property in their package.json file.

This is arbitrary script and can be run with npm run lint

scripts:{
    ....
    lint: jshint index.js lib/*.js test/*.js,
    ....
    lint: jshint lib/*.js test/*.js test/*/*.js
    ....
}

Naming your test folder

test vs. tests vs. tst or even using directories: in package.json

test modules and devDependencies

Please do not put test harnesses or transpilers in your dependencies object. See devDependencies, below.

Most of used modules use this correctly anyway, for mocha and tap based project.

Other patterns seen

TODO: finish the texts

directories: {
  test: tests
}

// in domutils/package.json

Lessons learned

How npm handles the scripts field

Must read: https://docs.npmjs.com/misc/scripts

Flexible definition of test frameworks

{
  devDependencies: {
    tap: ,
    mocha:
  },
  scripts: {
    test-tap: tap tst/*.js,
    test-mocha:mocha -R list .,

    test:npm run test-mocha
  }
}

Combining test from multile steps

{
  "devDependencies": {
    "tap": "",
    "mocha": "",
    "nsp": "",
    "jshint": ""
  },
  "scripts": {
    "test-tap": "tap tst/*.js",
    "test-mocha": "mocha -R list .",
    "lint": "jshint test/test.js",
    "test-security": "npm shrinkwrap && nsp audit-shrinkwrap",


    "test": "npm run test-mocha && npm run lint && npm run test-security"
  }
}   

This features also nsp, nodesecurity project, to check your dependencies for known vulnerabilities as part of test process.

tap vs. mocha vs. vows vs. ...

Currently I use mocha on my projects. Based on my dependency modules analyzed the tap seems more popular however.

In global mocha seems to be most popular an raising. see www.npm-stats.com for charts: vows, tap and mocha

Wednesday, December 3, 2014

plato

Watching some videos from Reject JS I have learned about plato: JavaScript source code visualization, static analysis, and complexity tool. Since this is my area of interest (one of and currently) I have started a small project, plato-reports and it took me several trials and errors to make a github hosted browsable copy here analysing npm (and other packages) using this tool. It produces some charts and metrics (avg shell be histograms, and loading of large project shell be faster) but: pictures are nice and metrics inspiring: