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:

Wednesday, March 26, 2014

Dojo and usage of has()

Quote from: http://livedocs.dojotoolkit.org/dojo/has Browser sniffing and feature inference are flawed techniques for detecting browser support in client side JavaScript. So lets face the truth, dojo's own code base and how many time has(something) is used
62 "ie"
14 "quirks"
14 "dojo-sync-loader"
12 "webkit"
11 "extend-dojo"
10 "opera"
 9 "touch"
 9 "host-browser"
 7 "safari"
 7 "mozilla"
 7 "dojo-combo-api"
 5 "mac"
 5 "dom-addeventlistener"
 5 "dojo-trace-api"
 5 "bug-for-in-skips-shadowed"
 4 "ios"
 4 "highcontrast"
 4 "dom"
 4 "dojo-requirejs-api"
 4 "config-deferredInstrumentation"
 4 "chrome"
 3 'activex'
 3 "khtml"
 3 "host-rhino"
 3 "host-node"
 3 "ff"
 3 "dojo-v1x-i18n-Api"
 3 "dojo-preload-i18n-Api"
 3 "dojo-loader-eval-hint-url"
 3 "dojo-loader"
 3 "dojo-inject-api"
 3 "dojo-config-api"
 3 "config-useDeferredInstrumentation"
 3 "config-dojo-loader-catches"
 3 "android"
 3 "air"
 2 name
 2 'native-xhr'
 2 'config-dojoBlankHtmlUrl'
 2 "trident"
 2 "ie-event-behavior"
 2 "dom-qsa2.1"
 2 "dojo-unit-tests"
 2 "dojo-undef-api"
 2 "dojo-publish-privates"
 2 "dojo-log-api"
 2 "dojo-debug-messages"
 2 "dojo-cdn"
 2 "dojo-amd-factory-scan"
 2 "array-extensible"
 1 term
 1 'script-readystatechange'
 1 'native-xhr2'
 1 'native-formdata'
 1 'mozilla'
 1 'host-node'
 1 'host-browser'
 1 'dom-qsa2.1'
 1 'dom-parser'
 1 'dojo-force-activex-xhr'
 1 'config-useXDomain'
 1 'config-requestProvider'
 1 "wii"
 1 "rtl-adjust-position-for-verticalScrollBar"
 1 "position-fixed-support"
 1 "native-xhr"
 1 "json-stringify"
 1 "json-parse"
 1 "jscript"
 1 "events-mousewheel"
 1 "events-keypress-typed"
 1 "event-stopimmediatepropagation"
 1 "event-orientationchange"
 1 "event-focusin"
 1 "dom-quirks"
 1 "dom-qsa3"
 1 "dom-qsa"
 1 "dom-parser"
 1 "dom-matches-selector"
 1 "dom-compliant-qsa"
 1 "dom-attributes-specified-flag"
 1 "dom-attributes-explicit"
 1 "dojo-timeout-api"
 1 "dojo-test-sniff"
 1 "dojo-sniff"
 1 "dojo-moduleUrl"
 1 "dojo-modulePaths"
 1 "dojo-has-api"
 1 "dojo-guarantee-console"
 1 "dojo-force-activex-xhr"
 1 "dojo-fast-sync-require"
 1 "dojo-enforceDefine"
 1 "dojo-dom-ready-api"
 1 "dojo-config-require"
 1 "dojo-config-addOnLoad"
 1 "dojo-built"
 1 "css-user-select"
 1 "config-tlmSiblingOfDojo"
 1 "config-stripStrict"
 1 "config-selectorEngine"
 1 "config-publishRequireResult"
 1 "config-_allow_leaks"

Tuesday, March 11, 2014

ios-driver

Using iOS version 7.1 iOS >= 6.0. Safari and hybrid apps are supported. No they are not !!!

Sunday, January 5, 2014

jsPerf tests for split join replace

Today I have found this code in connect middleware: exports.normalizeSlashes = function normalizeSlashes(path) { return path.split(sep).join('/'); }; So I have immediately jumped to jsPerf and wanted to compare this to alternative methods (for speed). Unlucky as always, I have run into several nonsense tests:
  • http://jsperf.com/split-join-vs-replace-47 - Both revisions 1,2 are wrong not comparing the same things
  • http://jsperf.com/regexp-vs-split-join2 - another treasure
and we could you with the list. Again and again, broken tests and misleading measurements. Please all of you who run into this article, and write or use jsPerf results please read using-jsperf-correctly.

BTW: there is enough room for fiddling elsewhere. On of the tips: "http://jsfiddle.net"

Of course split/join is much slower then intuitive replace. At least with browsers and JSPerf

Update 2013-01-06:

Irony: I have authored BUGGY TEST AS WELL: http://jsperf.com/normalizeslashes-split-join-vs-replace and I hope fixed version 2 is better ;-) http://jsperf.com/normalizeslashes-split-join-vs-replace/2

Sunday, November 17, 2013

rvm and ruby for some beEF on OSX

There are many articles, some of them did not work for me and may not work for you… This is what I have made to succeed:

# uninstall all previous trials of rvm (modify .bash_profile and remove)
rm -rf .rvm*
# latest stable in my time was 2.0.0-p247
curl -L https://get.rvm.io | bash -s stable --ruby
# obviously this install does not modify profile
source ~/.rvm/scripts/rvm
# just looking
rvm list known
ruby --version
# switch from apples version ruby 1.8.7 to "latest"
rvm use ruby-2.0.0-p247
#
rvm gemset create beef
rvm use ruby-2.0.0-p247@beef
# swich to cloned source 
cd ~/beef/
# make ruby in this folder to be 2.0.0
echo 'rvm use ruby-2.0.0-p247@beef' > .rvmrc
# install
bundle install

# run
source ~/.rvm/scripts/rvm
rvmsudo ./beef

Monday, July 29, 2013

git whatever --recursive (submodules)

Git submodules are pain in the ... some commands support --recursive but not all. In this case, this snipped can help:
git-recursive(){
 git "$@"
 git submodule foreach --recursive \
  git "$@" 
}
any improvements are welcomed ;-)

Thursday, July 18, 2013

DBA_TAB_COLS and friends

Table                Scope                Types     Hidden_Cols_Filtered
----------------------------------------------------------------------
DBA_TAB_COLS        in the database      T,W,C      No
DBA_TAB_COLUMNS     in the database      T,W,C      Yes

ALL_TAB_COLS        accessible to user   T,W,C      No
ALL_TAB_COLUMNS     accessible to user   T,W,C      Yes

USER_TAB_COLS       owned by user        T,W,C      No
USER_TAB_COLUMNS    owned by user        T,W,C      Yes




all_table_cols  mistype of ALL_TAB_COLS
user_table_cols mistype of USER_TAB_COLS

Wednesday, July 10, 2013

How much is Twitter Button (on OTN)

Just another funny fact: for such a small button down on the page, grey and almost invisible
you pay 27K on transfer ?
Sorry, just playing with Charles (before uninstalling this annoying freeware) from my Mac. Oh, refer(r)er is http://www.oracle.com/technetwork/index.html

Oracle and JQuery

Just a funny payload from todays random sniffing:
/*!
######################################################

# JQUERY.JS

# OCOM GLOBAL ASSET RELEASE: v3.3.2

# BUILD DATE: TUE JUN 25 01:03:40 UTC 2013

# COPYRIGHT ORACLE CORP 2013 [UNLESS STATED OTHERWISE]

# ANY CHANGES MADE TO THIS FILE WILL BE OVERWRITTEN!
# DO NOT MODIFY THIS FILE ON STAGE OR PRODUCTION. ALL
# CHANGES OR ADDITIONS TO THIS FILE MUST BE SUBMITTED
# TO WEBSTANDARDS_WW -AT- ORACLE.COM

######################################################
*/

/*! jQuery v1.7.1 jquery.com | jquery.org/license */
(function(a,b){function cy(a){return f.isWindow(a)?a:a.nodeType===9?a.defaultView||a.parentWindow:!1}function cv(a){if(!ck[a]){var b=c.body,d=f("<"+a+">").appendTo(b),
......

Spring Config Files, Locations, Names and Structures

Quickly finding all spring config files
spring-configs(){
 git grep --name-only "http://www.springframework.org/" -- '*.xml' 
}
Now let's compare several "boilerplate, demo, sample projects" (just from what I have on my hd):

PetClinic: https://github.com/SpringSource/spring-petclinic/

src/main/resources/spring/business-config.xml
src/main/resources/spring/datasource-config.xml
src/main/resources/spring/mvc-core-config.xml
src/main/resources/spring/mvc-view-config.xml
src/main/resources/spring/tools-config.xml
src/test/java/org/springframework/samples/petclinic/web/VisitsViewTests-config.xml

STS Wizard generated project (Templated Project, MVC)

src/main/webapp/WEB-INF/spring/appServlet/servlet-context.xml
src/main/webapp/WEB-INF/spring/root-context.xml

STS Wizard generated project (Templated Project, Utility)

src/main/resources/META-INF/spring/app-context.xml
src/test/resources/x/y/z/ExampleConfigurationTests-context.xml

Spring Roo Project (STS Wizard)

src/main/resources/META-INF/spring/applicationContext.xml

DI Styles (SpringSourceDemonstration) https://github.com/cbeams/distyles.git

style-1-xml/src/main/com/bank/config/app-config.xml
style-2-namespace/src/main/com/bank/config/app-config.xml
style-3-autowired/src/main/com/bank/config/app-config.xml
style-5-hybrid/src/main/com/bank/config/app-config.xml
More Projects, Explanations and some Wrapup comming soon.

Thursday, July 4, 2013

XmlHttpRequest (XHR) and HTTP Redirects (testcase)

This is results of XHR behaviour in IE and Chrome regarding redirects. Enjoy.
Credits: dojo@gratex.com

Monday, June 24, 2013

Life Behind Proxy - gradle

today, brought another challenge, making gradlew/gradle working from behind corporate proxy. Solution/Failure article comming soon I hope. Update: 23:11 I gave up, proxy scanning makes all unusable, instead of configuring proxy changing repository URL to local nexus.
sed -i "s;repo.springsource.org/libs-milestone;nexushost/nexus/content/groups/public;" build.gradle
TODO: some "global" remapping line in .m2 ? without touching each build.gradle ?

Tuesday, June 11, 2013

webmessaging, postMessage and naive properties access

Sometimes I tend to put debug codes to dump method arguments. My favorite construction is
console.debug("dumpEvent:", evt); 
instead of often seen:
console.debug("dumpEvent:"+evt);
However, using this code is not a good idea with cross domain integration code:
win.global.addEventListener("message", dumpEvent);
function dumpEvent(evt) {
 // this will raise some errors in console
 // Blocked a frame with origin "http://a" from accessing 
 // a frame with origin "http://b". 
 // Protocols, domains, and ports must match.
 console.debug("dumpEvent", evt); // not a good idea
}

win.global.addEventListener("message", dumpEventProperties);
function dumpEventProperties(evt) {
 // this shall work, dump only properies specified in: 
 // http://www.w3.org/TR/webmessaging/
 console.debug("dumpEvent", {
  data : evt.data,
  origin : evt.origin,
  lastEventId : evt.lastEventId,
  //source : evt.source, //and this is the cause of problem ;-)
  ports : evt.ports
 });
}
So be aware, sometimes your logging statements can produce errors as well ;-)