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.