Friday, September 9, 2011

libevent2 mingw

Tried libevent2 libevent-2.0.13-stable.tar.gz 
on MinGW.


Didn't work.


event-config.h wasn't being created by make..


The make target was



./include/event2/event-config.h: config.h
/usr/bin/mkdir -p ./include/event2
echo '/* event2/event-config.h' > $@
echo ' *' >> $@
echo ' * This file was generated by autoconf when libevent was built, and post-' >> $@
echo ' * processed by Libevent so that its macros would have a uniform prefix.' >> $@
echo ' *' >> $@
echo ' * DO NOT EDIT THIS FILE.' >> $@
echo ' *' >> $@
echo ' * Do not rely on macros in this file existing in later versions.'>> $@
echo ' */' >> $@
echo '#ifndef _EVENT2_EVENT_CONFIG_H_' >> $@
echo '#define _EVENT2_EVENT_CONFIG_H_' >> $@


sed -e 's/#define /#define _EVENT_/' \
   -e 's/#undef /#undef _EVENT_/' \
   -e 's/#ifndef /#ifndef _EVENT_/' < config.h >> $@
echo "#endif" >> $@



Since MSYS' make failed to create event-config.h .. here is the shell script





Monday, July 11, 2011

Sunday, June 12, 2011

Les Paul Encoding

http://www.google.com/logos/2011/lespaul.html

#tune=

The data has the format:


can be 0 or 1. 

If is 0, is 4 bits.

If is 1, is 10 bits.

can be 0 or 1.

If is 0, is 5 bits.

If is 1, is 20 bits.

So, the maximum datagram, word, chunk, or whatever is 32 bits. The smallest chunk is 11 bits.

There are 10 notes. And their values are (lowest note to the highest):
2, 6, 3, 0, 7, 1, 8, 4, 9, 5
do, re, mi, fa, sol, la, ti, do, re, mi.

For a monophonic chunk ( is 0), is 4 bits but reversed.
For example, for ti (value is 8 base 10), it is 0001, not 1000.

For a polyphonic chunk ( is 1), is 10 bits. NOT reversed.
For example, for fa, la, do (0, 1, 4 base 10),  it is 1100100000   (index 0, 1, 4 are set).

is always reversed. It could be 5 bits (less than 32) or 20 bits.
Probably the unit is 1/10 milliseconds..

TODO: write a program that actually demonstrates this.

Thursday, March 31, 2011

SSH tip

ssh root@somehost
... takes a long time before password prompt

So, in ~/.ssh/config:

GSSAPIAuthentication no



Wednesday, March 16, 2011

how flash ads get your cookie

A Flash advertisement, hosted on http://ad.com/ad.swf, displayed on http://yoursite.com, can get cookie and send it to ad.com.

Example setup: http://pastehtml.com/view/1dntfa4.html

A swf is hosted on dl.dropbox.com. And it gets document.cookie of pastehtml.com and sends it to dl.dropbox.com.

The swf is using ExternalInterface.call() to execute arbitrary javascript.
This technique is explained here:
http://lcamtuf.blogspot.com/2011/03/other-reason-to-beware-of.html

Code:


So, you can execute arbitrary javascript by passing a string to ExternalInterface.call():

"\\"));    YOUR SCRIPT HERE      }catch(e){}//"" 

And, you can do cross domain xhr using swf (only to the domain where swf is hosted at).

Sunday, January 2, 2011

minecraft ubuntu ibus keyboard problem

ibus blocks input for minecraft or some java games (https://bugs.launchpad.net/ubuntu/+source/ibus/+bug/481656)

so, launch those java programs with XMODIFIERS=

XMODIFIERS= java -Xmx512M -cp Minecraft.jar net.minecraft.LauncherFrame

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