Friday, December 9, 2011
factor listener change font size
To change listener's font size:
( scratchpad ) USING: pango.cairo
( scratchpad ) 120 dpi set-global
( scratchpad ) save
( scratchpad )
Juniper VPN on Archlinux 64 bit.
http://www.rz.uni-karlsruhe.de/~iwr91/juniper/
~/.juniper_networks/network_connect/config/foo.conf
host=vpn.your.host.com
user=your.user.name
realm=view source on the vpn welcome page and search for realm
cafile=/etc/ssl/certs/ca.pem
certfile=
Then, you can do
$ sudo vim /etc/pacman.conf
And, uncomment
[multilib]
Include = /etc/pacman.d/mirrorlist
$ sudo pacman -Sy lib32-glibc lib32-zlib lib32-nss lib32-gcc-libs net-tools
$ jnc --nox foo
$ sudo vim /etc/resolve.conf
And change nameserver order.
Thursday, December 1, 2011
archbang testing
It turned out I had a working harddisk. Archbang is installed on the desktop.
The desktop PC is a6114x .
The default font, Deja Vu Mono did not display underscore character. Seems like that font isn't good. pacman -S ttf-inconsolata
$ grep font ~/.Xdefaults
URxvt*font: xft:Inconsolata-16
$ grep font ~/.gvimrc
set guifont=Inconsolata\ Medium\ 16
I have usb interface (old maudio fast track). .asoundrc
pcm.dmixed {
type dmix
ipc_key 1024
slave {
pcm "hw:1,0"
}
}
pcm.!default {
type plug
slave.pcm "dmixed"
}
ctl.!default {
type hw
card 1
}
where card 1 is Track [Fast Track], device 0: USB Audio [USB Audio]
Also, to set audio card ordering:
/etc/modprobe.d/alsa.conf:
options snd slots=snd-hda-intel,snd-usb-audio
# http://alsa.opensrc.org/MultipleCards#The_newer_.22slots.3D.22_method
My graphics card that is part of motherboard is
00:0d.0 VGA compatible controller: nVidia Corporation C61 [GeForce 6150SE nForce 430] (rev a2)
$ cat /etc/X11/xorg.conf.d/10-monitor.conf
Section "Monitor"
Identifier "Monitor0"
EndSection
Section "Device"
Identifier "Device0"
Driver "nvidia" #Choose the driver used for this monitor
EndSection
Section "Screen"
Identifier "Screen0" #Collapse Monitor and Device section to Screen section
Device "Device0"
Monitor "Monitor0"
DefaultDepth 24 #Choose the depth (16||24)
SubSection "Display"
Depth 24
Modes "1280x1024_75.00" "1024x768_75.00" #Choose the resolution
EndSubSection
EndSection
I like to swap ctrl and caps lock.
$ grep ctrl ~/.config/openbox/autostart
setxkbmap -option ctrl:swapcaps
I like W-w to show all applications, W-q to shutdown.
~/.config/openbox/rc.xml
I tried to set up juniper vpn but failed. Went all the way to installing 32bit java.. But not worth it.
I need to install VirtualBox.
Friday, September 9, 2011
libevent2 mingw
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
#tune=
The data has the format:
If
If
If
If
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 (
For example, for ti (value is 8 base 10), it is 0001, not 1000.
For a polyphonic chunk (
For example, for fa, la, do (0, 1, 4 base 10), it is 1100100000 (index 0, 1, 4 are set).
Probably the unit is 1/10 milliseconds..
TODO: write a program that actually demonstrates this.
Thursday, March 31, 2011
SSH tip
... takes a long time before password prompt
So, in ~/.ssh/config:
GSSAPIAuthentication no
Wednesday, March 16, 2011
how flash ads get your cookie
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
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
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
- download extjs
- unzip the file
- cd extjs-3.1.1/docs
- python -m SimpleHTTPServer 8080
- http://localhost:8080
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
Sunday, August 8, 2010
lua readline tab completion
#!/bin/bash
LUA_HOME="$HOME/opt/lua"
LUA_PATH="$LUA_PATH;$LUA_HOME/?.lua" LUA_CPATH="$LUA_CPATH;$LUA_HOME/?.so" "$LUA_HOME/bin/lua" -lreadline -lcomplete $*
where readline and complete are from http://lua-users.org/wiki/CompleteWithReadline
use readline.c and complete.lua. You don't have to patch lua.c.
read http://www.lua.org/manual/5.1/manual.html#pdf-package.loaders to know how to use LUA_PATH and LUA_CPATH. question mark (?) in LUA_PATH or LUA_CPATH is replaced with foo when you do require("foo"). And, when you do require("foo.bar"), it searches for foo/bar.lua or foo/bar.so if LUA_(C)PATH.
Friday, February 26, 2010
LLVM build on MinGW
building llvm-2.6
- download and install MinGW
- download and install cmake
- download llvm
- tar xvzf llvm-2.6.tar.gz
- mkdir llvm-cmake
- cd llvm-cmake
- cmake -G "MinGW Makefiles" ..\llvm-2.6
- it'll fail
- open CMakeCache.txt
- write CMAKE_C_COMPILER_ENVVAR:FILEPATH=C:/MinGW/bin/gcc.exe
- cmake -G "MinGW Makefiles" ..\llvm-2.6
- mingw32-make
For llvm 2.7,
- unzip llvm-2.7
- unzip clang source under llvm-27/tools/clang
- cd llvm-cmake
- cmake -G "MinGW Makefiles" -DCMAKE_INSTALL_PREFIX="/home/opt/llvm" ..\llvm-2.7
- mingw32-make DESTDIR=C: install
Tuesday, February 16, 2010
v8 on mingw
- install python
- install scons
- install svn
- checkout v8
svn checkout http://v8.googlecode.com/svn/trunk/ v8 - edit Sconstruct and comment out
-Werror(maybe there's a way to disable it from command line)vim v8/SConstruct cd v8sconsg++ -Iinclude samples\shell.cc libv8.a -lwinmm -lws2_32 -o v8.exe
Saturday, December 12, 2009
adds openconsole right click context:
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Software\Classes\Folder\shell]
[HKEY_CURRENT_USER\Software\Classes\Folder\shell\openconsole]
[HKEY_CURRENT_USER\Software\Classes\Folder\shell\openconsole\command]
@="\"C:\\home\\opt\\Console2\\bin\\release\\Console.exe\" -d \"%L\""
adds openbash right click context (needs msys and Console2 tab named "Bash" where shell is set to C:\msys\1.0\bin\bash.exe):
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Software\Classes\Folder\shell]
[HKEY_CURRENT_USER\Software\Classes\Folder\shell\openbash]
[HKEY_CURRENT_USER\Software\Classes\Folder\shell\openbash\command]
@="\"C:\\home\\opt\\Console2\\bin\\release\\Console.exe\" -t Bash -d \"%L\""
Tuesday, October 13, 2009
elb-create-lb
Friday, September 18, 2009
windows batch file to convert videos to mp3
@echo off
setlocal
set filename=%~n1
set filepath=%~df1
set dirname=%~dp1
set dumpfile=%dirname%\audiodump.wav
set outfile=%dirname%\%filename%.mp3
mplayer -ao pcm:fast -af volnorm -vo null -vc null "%filepath%" -dumpfile "%dumpfile%"
lame -h "%dumpfile%" -o "%outfile%"
del "%dumpfile%"
pause
endlocal
and drag and drop the movie to the batch file
Saturday, August 22, 2009
clojure tab completion on windows
windows sucks because it does.
so, clji.bat:
@echo off
setlocal
set CLOJURE_HOME=%~dp0\clojure
set CLASS_PATH=%CLOJURE_HOME%\jline-0.9.94.jar;%CLOJURE_HOME%\clojure.jar;%CLOJURE_HOME%\clojure-contrib.jar
java -Djline.words="%CLOJURE_HOME%\all_names.txt" -cp "%CLASS_PATH%" jline.ConsoleRunner clojure.main %*
endlocal
clj.bat:
@echo off
setlocal
set CLOJURE_HOME=%~dp0\clojure
set CLASS_PATH=%CLOJURE_HOME%\jline-0.9.94.jar;%CLOJURE_HOME%\clojure.jar;%CLOJURE_HOME%\clojure-contrib.jar
IF (%1)==() (
java -Djline.words="%CLOJURE_HOME%\all_names.txt" -cp "%CLASS_PATH%" jline.ConsoleRunner clojure.main
) ELSE (
java -Djline.words="%CLOJURE_HOME%\all_names.txt" -cp "%CLASS_PATH%" clojure.main %1 -- %*
)
endlocal
clji.bat always starts repl. clj.bat starts repl when no argument is passed. otherwise, it runs the first argument (should be .clj script).
it expects there's clojure/ directory at the same level of the batch files.
the directory should have some jar files (clojure.jar, clojure-contrib.jar, jline..)
and also clojure/ contains allnames.txt that is generated by allnames.clj:
(def all-names (concat (map (fn [p] (keys (ns-publics (find-ns p))))
'(clojure.core clojure.set clojure.xml clojure.zip))))
(println (apply str
(interleave (reduce concat all-names)
(repeat "\n"))))
to run it:
$ clj all_names.clj > all_names.txt
now, modified ConsoleRunner.java (from http://jline.sf.net) that'll actually use all_names.txt:
/*
* Copyright (c) 2002-2007, Marc Prud'hommeaux. All rights reserved.
*
* This software is distributable under the BSD license. See the terms of the
* BSD license in the documentation provided with this software.
*/
package jline;
import java.io.*;
import java.util.*;
/**
* <p>
* A pass-through application that sets the system input stream to a
* {@link ConsoleReader} and invokes the specified main method.
* </p>
* @author <a href="mailto:mwp1@cornell.edu">Marc Prud'hommeaux</a>
*/
public class ConsoleRunner {
public static final String HISTORY = "jline.history";
public static final String WORDS = "jline.words";
public static String[] getWords(String wordsFile) {
List result = new ArrayList();
try {
BufferedReader input = new BufferedReader(
new FileReader(wordsFile)
);
try {
String line = null;
while (null != (line = input.readLine())) {
result.add(line);
}
} finally {
input.close();
}
} catch (FileNotFoundException err) {
err.printStackTrace();
} catch (IOException err) {
err.printStackTrace();
}
String[] array = new String[result.size()];
result.toArray(array);
return array;
}
public static void main(final String[] args) throws Exception {
String historyFileName = null;
List argList = new ArrayList(Arrays.asList(args));
if (argList.size() == 0) {
usage();
return;
}
historyFileName = System.getProperty(ConsoleRunner.HISTORY, null);
// invoke the main() method
String mainClass = (String) argList.remove(0);
// setup the inpout stream
ConsoleReader reader = new ConsoleReader();
if (historyFileName != null) {
reader.setHistory(new History (new File
(System.getProperty("user.home"),
".jline-" + mainClass
+ "." + historyFileName + ".history")));
} else {
reader.setHistory(new History(new File
(System.getProperty("user.home"),
".jline-" + mainClass + ".history")));
}
String wordsFileName = System.getProperty(WORDS, null);
if (null != wordsFileName) {
//List list = new ArrayList();
//list.add(new SimpleCompletor(getWords(wordsFileName)));
//list.add(new FileNameCompletor());
//list.add(new NullCompletor());
Completor completor =
new MultiCompletor(new Completor[] {
new SimpleCompletor(getWords(wordsFileName))
, new FileNameCompletor()
});
reader.addCompletor(
new ArgumentCompletor(new Completor[] {
completor
, completor
}, new SExpr())
);
} else {
}
String completors = System.getProperty
(ConsoleRunner.class.getName() + ".completors", "");
List completorList = new ArrayList();
for (StringTokenizer tok = new StringTokenizer(completors, ",");
tok.hasMoreTokens();) {
completorList.add
((Completor) Class.forName(tok.nextToken()).newInstance());
}
if (completorList.size() > 0) {
reader.addCompletor(new ArgumentCompletor(completorList));
}
//reader.setCompletionHandler(new CandidateListCompletionHandler());
ConsoleReaderInputStream.setIn(reader);
try {
Class.forName(mainClass).
getMethod("main", new Class[] { String[].class }).
invoke(null, new Object[] { argList.toArray(new String[0]) });
} finally {
// just in case this main method is called from another program
ConsoleReaderInputStream.restoreIn();
}
}
private static void usage() {
System.out.println("Usage: \n java " + "[-Djline.history='name'] "
+ "[-Djline.words=<path to words file for autocompletion>] "
+ ConsoleRunner.class.getName()
+ " <target class name> [args]"
+ "\n\nThe -Djline.history option will avoid history"
+ "\nmangling when running ConsoleRunner on the same application."
+ "\n\nargs will be passed directly to the target class name.");
}
}
class SExpr
extends ArgumentCompletor.AbstractArgumentDelimiter {
public boolean isDelimiterChar(String buffer, int pos) {
String c = buffer.substring(pos, pos+1);
return c.matches("[^\\w-*<>=?]");
}
}
if -Djline.words=path/to/file/that/has/word/list is passed, it'll use that
file to do tab completion.
it's quick and dirty. i don't get how jline works.
somehow, i had to pass completor (new MultiCompletor(...)) twice to ArgumentCompletor so that
tab completion works into middle of line.
Also, SExpr is argument delimiter that considers things other than [\w-*<>=?]
a delimiter.
so, run mvn package to build jline jar. then put jline jar file under clojure/.
then clj.bat and clji.bat would work.
i always spend time to set up development environment then lose interest :P