export http_proxy="http://localhost:8118"
Tuesday, November 27, 2012
python program behind proxy
All about pip
I was stucked in pip. Just found out that pip is called "pip-python" in RHEL.
What's more, pip cannot auto detect system proxy settings, manual specify:
sudo pip sudo pip-python install virtualenv --proxy localhost:8118
What's more, pip cannot auto detect system proxy settings, manual specify:
sudo pip sudo pip-python install virtualenv --proxy localhost:8118
Sunday, November 11, 2012
command sort on last column
As you know, the linux sort command is agile, which can sort on column using -k.
However, if we gonna sort on the last column and each row has different number of columns, we can still achieve that with the help of sed.
However, if we gonna sort on the last column and each row has different number of columns, we can still achieve that with the help of sed.
sed 's/^\(.\+\s\+\)\([0-9]\+ *\)$/\2 \1/'
Thursday, November 8, 2012
Online bood recommened
A page list downloadable book:
http://cfajohnson.com/computers/pdflinks.shtml
I'm gonna go through the following:
The GNU/Linux Advanced Administration
http://www.tldp.org/LDP/Bash-Beginners-Guide/Bash-Beginners-Guide.pdf
http://www.tldp.org/LDP/abs/abs-guide.pdf
http://www.greenteapress.com/thinkpython/thinkpython.pdf
http://cfajohnson.com/computers/pdflinks.shtml
I'm gonna go through the following:
The GNU/Linux Advanced Administration
http://www.tldp.org/LDP/Bash-Beginners-Guide/Bash-Beginners-Guide.pdf
http://www.tldp.org/LDP/abs/abs-guide.pdf
http://www.greenteapress.com/thinkpython/thinkpython.pdf
Tuesday, October 2, 2012
zsh cd tab completion slow
It is quite annoing that zsh seems stuck when completion using tab in a huge directory.
To speed up the zsh completion, append the following lines to ~/.zshrc
# Speed up the zsh completion
zstyle ':completion:*' accept-exact '*(N)'
zstyle ':completion:*' use-cache on
zstyle ':completion:*' cache-path ~/.zsh/cache
Sometimes, the directory auto completion works slow under git and svn directories.The solution is to disable it from getting git info and svn info:
For GIT, add following to .zshrc:
For SVN, append this line to .zshrc:
To speed up the zsh completion, append the following lines to ~/.zshrc
# Speed up the zsh completion
zstyle ':completion:*' accept-exact '*(N)'
zstyle ':completion:*' use-cache on
zstyle ':completion:*' cache-path ~/.zsh/cache
Sometimes, the directory auto completion works slow under git and svn directories.The solution is to disable it from getting git info and svn info:
For GIT, add following to .zshrc:
__git_files () {
_wanted files expl 'local files' _files
}
For SVN, append this line to .zshrc:
compdef -d svn
Friday, August 3, 2012
Make GridColumns align in two different Grids in WPF XAML
In XAML UI, some times we want to make GridColumn Width synchronized with other GridColumns in other Grids.
WPF provided a property called SharedSizeGroup which allows sizing properties shared between ColumnDefinition or RowDefinition.
And remeber to set Grid.IsSharedSizeScope="True".
However , when we want one column take up all the available space, like the example above. You will find out that even you write Width="*" still doesn't work as SharedSizeGroup will make it as short as possible.
My solution is , Shared all the columns size except the one contain TextBox.
<Grid Grid.IsSharedSizeScope="True">
<Grid.RowDefinitions>
<RowDefinition Height="auto"/>
<RowDefinition Height="auto"/>
</Grid.RowDefinitions>
<Grid Name="Grid1">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="auto" SharedSizeGroup="a" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="auto" SharedSizeGroup="c"/>
<ColumnDefinition Width="auto" SharedSizeGroup="d"/>
WPF provided a property called SharedSizeGroup which allows sizing properties shared between ColumnDefinition or RowDefinition.
And remeber to set Grid.IsSharedSizeScope="True".
However , when we want one column take up all the available space, like the example above. You will find out that even you write Width="*" still doesn't work as SharedSizeGroup will make it as short as possible.
My solution is , Shared all the columns size except the one contain TextBox.
<Grid Grid.IsSharedSizeScope="True">
<Grid.RowDefinitions>
<RowDefinition Height="auto"/>
<RowDefinition Height="auto"/>
</Grid.RowDefinitions>
<Grid Name="Grid1">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="auto" SharedSizeGroup="a" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="auto" SharedSizeGroup="c"/>
<ColumnDefinition Width="auto" SharedSizeGroup="d"/>
</Grid.ColumnDefinitions>
....
</Grid>
<Grid Name="Grid2">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="auto" SharedSizeGroup="a" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="auto" SharedSizeGroup="c"/>
<ColumnDefinition Width="auto" SharedSizeGroup="d"/>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="auto" SharedSizeGroup="a" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="auto" SharedSizeGroup="c"/>
<ColumnDefinition Width="auto" SharedSizeGroup="d"/>
</Grid.ColumnDefinitions>
.........
</Grid>
Thursday, August 2, 2012
WPF XAML GridSplitter Style
<Style x:Key="gridSplitterStyle" TargetType="{x:Type GridSplitter}">
<Setter Property="FrameworkElement.Height" Value="6"/>
<Setter Property="TextElement.Foreground" Value="#FF204D89" />
<Setter Property="Border.BorderThickness" Value="0,0,0,0" />
<Setter Property="UIElement.SnapsToDevicePixels" Value="True" />
<Setter Property="UIElement.Focusable" Value="False" />
<Setter Property="FrameworkElement.Cursor" Value="SizeNS" />
<Setter Property="Control.Template">
<Setter.Value>
<ControlTemplate>
<Border BorderThickness="0,0,0,0" >
<Canvas Width="19" Height="3">
<Rectangle Fill="{TemplateBinding TextElement.Foreground}" Width="2" Height="2" Canvas.Left="0" Canvas.Top="0" />
<Rectangle Fill="{TemplateBinding TextElement.Foreground}" Width="2" Height="2" Canvas.Left="4" Canvas.Top="0" />
<Rectangle Fill="{TemplateBinding TextElement.Foreground}" Width="2" Height="2" Canvas.Left="8" Canvas.Top="0" />
<Rectangle Fill="{TemplateBinding TextElement.Foreground}" Width="2" Height="2" Canvas.Left="12" Canvas.Top="0" />
<Rectangle Fill="{TemplateBinding TextElement.Foreground}" Width="2" Height="2" Canvas.Left="16" Canvas.Top="0" />
</Canvas>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
Tuesday, July 17, 2012
Maven Create a web project
mvn archetype:generate -DgroupId=com.choiceengine -DartifactId=ChoiceEngineSpeedo -DarchetypeArtifactId=maven-archetype-webapp
Monday, June 25, 2012
VIM multiple clipboards(registers), without leaving insert model
To view your current registers type
:reg
. You'll notice that every register is prefixed with the symbol "
.
How do you use these things? Let's say you want to copy a line into a specific register:
"kyy
will yank the current line into register "k
. If you later want to paste register "k
you can do this: "kp
.
If you want to put without leaving insert model:
ctrl-r follwed by the register lets you paste the contents of a register without leaving insert mode.
Ctrl + r" Put from the default register
Ctrl + rd Put from register d
Thursday, June 21, 2012
Play on OpenShift
https://openshift.redhat.com/community/blogs/supporting-play-framework-on-openshift-with-the-diy-application-type
https://github.com/opensas/play2-openshift-quickstart
https://poll-opensas.rhcloud.com/assets/slides/slides.html#7
http://jee-bpel-soa.blogspot.com.au/2012/04/running-maven-applications-on-openshift.html
https://github.com/opensas/play2-openshift-quickstart
https://poll-opensas.rhcloud.com/assets/slides/slides.html#7
http://jee-bpel-soa.blogspot.com.au/2012/04/running-maven-applications-on-openshift.html
Thursday, June 14, 2012
Enable spell checking in VIM
This is a feature of VIM I should know decades ago:
Enable spell checking:
Enable spell checking:
:setlocal spell spelllang=en_us
- ]s — move to the next mispelled word
- [s — move to the previous mispelled word
- zg — add a word to the dictionary
- zug — undo the addition of a word to the dictionary
- z= — view spelling suggestions for a mispelled word
:set nospell
Saturday, June 9, 2012
Install bzr bazaar with out root privilege
Here are the steps that I followed to install bzr locally (in my user directory without root access) without using gcc.
Although you do not need to install it on your server, I still wanted to. The reason being that I cannot find any decent cgi that will let me browse the content of my bzr repository from the web. The easiest way is to install bzr and have it used by a script query and stat your repository from your web page.
So again, you do not need to install bzr on the server (for me, that was the whole point of using Bazaar in the first place). Still here’s how I got it to install:
Monday, June 4, 2012
unable to load the native components of sql server compact corresponding to the ado.net
This is a very stupid exception, which is due to SQL CE has mismatched binaries.
So, just uninstall SQL Server Compact 32 bit (64 bit as well for 64 bit machines) from Add/Remove Programs
Download sql server compact edition and install them.
So, just uninstall SQL Server Compact 32 bit (64 bit as well for 64 bit machines) from Add/Remove Programs
Download sql server compact edition and install them.
Monday, May 14, 2012
Simple python web server, RequestHandler
This is a simple python script to create a python HTTPServer handle GET request
-EOF-
#!/usr/bin/python from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer class Handler(BaseHTTPRequestHandler): def do_GET(self): #print self.headers print self.headers.getheader('Content-Length') self.wfile.write('HELLO!!!') server = HTTPServer(('', 58621), Handler) server.serve_forever()
-EOF-
Thursday, April 26, 2012
Git mergetool kdiff3 setting for Mac
[difftool "kdiff3"] path = /Applications/kdiff3.app/Contents/MacOS/kdiff3 trustExitCode = false [difftool] prompt = false [diff] tool = kdiff3 [mergetool "kdiff3"] path = /Applications/kdiff3.app/Contents/MacOS/kdiff3 trustExitCode = false [mergetool] keepBackup = false [merge] tool = kdiff3
Wednesday, April 11, 2012
Check Port Usage: who is taking my port 8080
Using this command to get the process id:
$ lsof -i :8080
$ lsof -i :8080
Tuesday, April 10, 2012
give Maven more memory, InvocationTargetException: Java heap space
give Maven more memory: in a bash shell, export MAVEN_OPTS=-Xmx1024M
Monday, April 9, 2012
Collaborative Filtering Resources, Java
I was doing collaborative filtering based on a large dataset. However the performance is not making me feel happy, so I am gonna switch to some third party library.
Other than Apach Mashout Tast, there are a few other:
EOF
Other than Apach Mashout Tast, there are a few other:
- Cofi - The library is used as part of the RACOFI web site which is a live Music Recommender site.
- CoFE - CoFE is short for "COllaborative Filtering Engine". CoFE was formerly known as CFEngine. CoFE will run as a server to generate recommendations for individual items, top-N recommendations over all items, or top-N recommendations limited to one item type. Recommendations are computed using a popular, well-tested nearest-neighbor algorithm (Pearson's algorithm). CoFE can be integrated with any system that supports Java. User data is stored in MySQL.
- Taste - Taste is a flexible, fast collaborative filtering engine for Java. Taste provides a rich set of components from which you can construct a customized recommender system from a selection of algorithms. Taste supports both memory-based and item-based recommender systems, slope one recommenders, and a couple other experimental implementations. It does not currently support model-based recommenders.
- Alkini Meme - Users express their tastes by assigning ratings to products. To model users so that they can be grouped together, Alkindi represents them geometrically as vectors in a high-dimensional space. The coordinate axes of this space correspond to products; the coordinates of the point representing a user are that user’s ratings of those products. Alkindi partitions its existing user base into clusters using “K-means”, a statistical algorithm that maximizes the geometric tightness of the clusters. Alkindi has developed a novel metric that smoothly integrates all available data. This helps alleviate the sparse data problem.
- RACOFI - RACOFI (Rule-Applying Collaborative Filtering) ia multidimensional rating system. It has been used where users rate contemporary music in the five dimensions of impression, lyrics, music, originality, and production. The collaborative filtering algorithms STI Pearson, STIN2, and the Per Item Average algorithms are employed together with RuleML-based rules to recommend music objects that best match user queries. The music rating system has been on-line since August 2003 at http://racofi.elg.ca.
- iRate - iRATE radio is a collaborative filtering system for music. You rate the tracks it downloads and the server uses your ratings and other people's to guess what you'll like.
- SWAMI - SWAMI is a framework for running collaborative filtering algorithms and evaluating the effectiveness of those algorithms. It uses the EachMovie dataset, generously provided by Compaq.
EOF
Monday, March 26, 2012
git diff ignore line ending
Different line ending is really annoying, here is the command to ignore line ending when diff:
$ git config --global core.autocrlf true
$ git config --global core.autocrlf true
Thursday, March 22, 2012
The difference between Scripting Languages: PHP, Perl, Python, Ruby
The difference between Scripting Languages: PHP, Perl, Python, Ruby.
http://hyperpolyglot.org/scripting?utm_source
http://hyperpolyglot.org/scripting?utm_source
Thursday, March 1, 2012
SSH without manually input password
On client side generate the ssh key:
client$ cd ~/.ssh
client$ ssh-keygen -q -f id_rsa -t rsa
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Copy the public key to the server:
# Step 1:
client$ scp ~/.ssh/id_rsa.pub user@your.ssh.server:~/.ssh/tmpfile
# Step 2:
server$ chmod 700 ~/.ssh
server$ cat ~/.ssh/tmpfile >> ~/.ssh/authorized_keys
server$ chmod 600 ~/.ssh/authorized_keys
server$ rm ~/.ssh/tmpfile
client$ cd ~/.ssh
client$ ssh-keygen -q -f id_rsa -t rsa
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Copy the public key to the server:
# Step 1:
client$ scp ~/.ssh/id_rsa.pub user@your.ssh.server:~/.ssh/tmpfile
# Step 2:
server$ chmod 700 ~/.ssh
server$ cat ~/.ssh/tmpfile >> ~/.ssh/authorized_keys
server$ chmod 600 ~/.ssh/authorized_keys
server$ rm ~/.ssh/tmpfile
Tuesday, February 21, 2012
GNOME Shell Extension development document
I don't know why it is so hard to search for the right development document for GNOME Shell Extension. The Gjs seems wraps all the functionalities to call the shell, but hard to find out how.
After searching and coding. I find out this may be a good one:
http://sander.github.com/tmp/gsdoc/documentation.html
After searching and coding. I find out this may be a good one:
http://sander.github.com/tmp/gsdoc/documentation.html
Wednesday, February 15, 2012
Recursively chmod directories only
find . -type d -exec chmod 755 {} \;
This will recursively search your directory tree (starting at dir ‘dot’) and chmod 755 all directories only.
Similarly, the following will chmod all files only (and ignore the directories):
find . -type f -exec chmod 644 {} \;
Wednesday, February 8, 2012
Shell eliminate warning messages
When I grep the directory, the warning message is really annoying.
$ grep ........ 2 > /dev/null
This will write warnings to /dev/null
$ grep ........ 2 > /dev/null
This will write warnings to /dev/null
Tuesday, February 7, 2012
Python regex replace part of matched string
myRe = re.compile(r"(myFunc\(.+?\,.+?\,)(.+?)(\,.+?\,.+?\,.+?\,.+?\))")
print myRe.sub(r'\1"noversion"\3', val)
Sunday, February 5, 2012
Saturday, February 4, 2012
GNOME Shell Extensions development
In order to develop the GNOME Shell Extensions, a few resources may be extremely helpful:
As the extensions will not be loaded it self when GNOME Shell starts, the extension uid need to be added:
$gsettings set org.gnome.shell enabled-extensions "['LittleRabbit@gosteven.com']"
then
$gsettings get org.gnome.shell enabled-extensions
it will be there
Few tips for development:
1. See the log and debug information: Press Alt+F2, type lg to open the Looking Glass. P.S. Currently the debug method is logging everything. Actually You can also force a gdb breakpoint from _javascript_ with "global.breakpoint();"
2. Make GNOME Shell reload extensions after modified js files without log out: Press Alt+F2, type r to refresh.
Few tips for development:
1. See the log and debug information: Press Alt+F2, type lg to open the Looking Glass. P.S. Currently the debug method is logging everything. Actually You can also force a gdb breakpoint from _javascript_ with "global.breakpoint();"
2. Make GNOME Shell reload extensions after modified js files without log out: Press Alt+F2, type r to refresh.
Sunday, January 29, 2012
mac lion terminal doesn't source profile
I have encountered the problem that my MacBook Pro ~/.profile doesn't been sourced in the terminal.
The solution is simple:
bash first runs /etc/profile. /etc/profile (on Mac OS X 10.6.7) runs path_helper(8) which is where your default paths get set. After that it runs /etc/bashrc which doesn't do much. Once the default configuration is set, it moves on to the user login scripts.
bash looks in your home directory for .bash_profile, .bash_login, and .profile in that order. bash will run the first of these that it finds and stop looking.
So, if you have a .bash_profile in the home directory, the .profile will be ignored. In this case, just append a line in .bash_profile:
The solution is simple:
bash first runs /etc/profile. /etc/profile (on Mac OS X 10.6.7) runs path_helper(8) which is where your default paths get set. After that it runs /etc/bashrc which doesn't do much. Once the default configuration is set, it moves on to the user login scripts.
bash looks in your home directory for .bash_profile, .bash_login, and .profile in that order. bash will run the first of these that it finds and stop looking.
So, if you have a .bash_profile in the home directory, the .profile will be ignored. In this case, just append a line in .bash_profile:
$cat "source ~/.profile" >> .bash_profile
Subscribe to:
Posts (Atom)