Thursday, December 16, 2010

llvm setup

LLVM Getting Started

mv ~/Downloads/clang-2.8 ~/Downloads/llvm-2.8/tools/clang
cd ~/Downloads/llvm-2.8
./configure --prefix=~/opt/llvm
make -j 12 
make install
cd ~/opt/llvm
ctags -R --c++-kinds=+p --fields=+iaS --extra=+q --language-force=C++ $HOME/opt/llvm/include
mv tags ~/.vim/tags/llvm

~/.vimrc

"au BufAdd,BufNewFile * nested tab sball
set tags+=~/.vim/tags/llvm
nmap <C-\> :tab split<CR>:normal evBy<CR>:exec "tag " . @"<CR>

Friday, December 10, 2010

Setting Node properties using SlingPostServlet

SlingPostServlet is handy


To have a multi-value property that has one value, use propname@TypeHint


curl -u admin:admin -F'foo=bar' -F'foo@TypeHint=String[]' http://localhost:8888/some/path


More stuff here: http://www.unc.edu/home/adamc/post-servlet.html


And here's script that lets you set up a test page if you are using Day CQ and ExtJS


#!/bin/bash

if (( $# < 1 ))
then
    echo "Creates /apps/sandbox/*"
    echo "Usage: $0 project_name [host] [cred]"
    echo "ex, $0 test-project localhost:4502 admin:admin"
    exit 1
fi

name="$1"
host="localhost:4502"
cred="admin:admin"

if (( $# >= 2 ))
then
    host="$2"
fi

if (( $# >= 3 ))
then
    cred="$3"
fi

path="/apps/sandbox/$name"
left="http://${host}${path}"
category="sandbox.$name"

function createComponent() {
curl -s -u "$cred" \
    -F'jcr:primaryType=cq:Component' \
    -F"sling:resourceType=$path" \
    "$left" > /dev/null 2>&1
}

function uploadJsp() {
curl -s -u "$cred" \
    -T - "$left/html.jsp" > /dev/null 2>&1 <<HEREDOC
<%@include file="/libs/foundation/global.jsp"%>
<%@page import="com.day.cq.widget.HtmlLibraryManager"%>
<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>$path</title>
    <%
    final HtmlLibraryManager manager = sling.getService(HtmlLibraryManager.class);
    if (manager != null) {
        manager.writeCssInclude(slingRequest, out, "$category");
        manager.writeJsInclude(slingRequest, out, "$category");
    } else {
        out.write("BAD");
    }
    %>
</head>
<body>
    <h1>Sandbox $name</h1>
</body>
</html>
HEREDOC
}

function createWidget() {
curl -s -u "$cred" \
    -F'jcr:primaryType=cq:ClientLibraryFolder' \
    -F'sling:resourceType=widgets/clientlib' \
    -F"categories=$category" \
    -F'categories@TypeHint=String[]' \
    -F'dependencies=cq.widgets' \
    -F'dependencies@TypeHint=String[]' \
    "$left/widgets" > /dev/null 2>&1
}

function uploadJsTxt() {
curl -s -u "$cred" \
    -T - "$left/widgets/js.txt" > /dev/null 2>&1 <<HEREDOC
#base=source
script.js
HEREDOC
}

function createSource() {
curl -s -u "$cred" \
    -F'jcr:primaryType=nt:folder' \
    "$left/widgets/source" > /dev/null 2>&1
}

function uploadJs() {
curl -s -u "$cred" \
    -T - "$left/widgets/source/script.js" > /dev/null 2>&1 <<HEREDOC
CQ.Ext.onReady(function() {
    //entry point
    CQ.Ext.Msg.alert('Sandbox $name', 'Hello World!');
});
HEREDOC
}

echo -n "creating cq:Component $path... "
createComponent || exit 1
echo "DONE"

echo -n "uploading html.jsp... "
uploadJsp || exit 1
echo "DONE"

echo -n "creating widgets... "
createWidget || exit 1
echo "DONE"

echo -n "uploading js.txt... "
uploadJsTxt || exit 1
echo "DONE"

echo -n "creating source directory... "
createSource || exit 1
echo "DONE"

echo -n "uploading script.js... "
uploadJs || exit 1
echo "DONE"

echo "You may visit: $left.html"

Thursday, December 9, 2010

reading extjs docs locally

  1. download extjs
  2. unzip the file
  3. cd extjs-3.1.1/docs
  4. python -m SimpleHTTPServer 8080
  5. http://localhost:8080
or, download Twisted and  twistd -n web --port=8080 --path=.

Thursday, December 2, 2010

ats on windows

to install ats on windows, you need cygwin.

in cygwin you need:

  • g++
  • make
  • gmp
  • maybe automake

then,

cd ats-x.x.x
./configure --prefix=/cygdrive/c/opt/ats
make

before make install, you need to modify Makefile.

  • find install: target
  • quote cd "$(abstopsrcdir)" && ..

and in ~/.bashrc, you need something like:

OPT_DIR=/cygdrive/c/home/opt
export ATSHOME="${OPT_DIR}/ats/lib/ats-anairiats-0.2.2"
export ATSHOMERELOC="ATS-0.2.2"
export PATH="$ATSHOME/bin:$PATH"

and atscc is available