Friday, January 30, 2015

Test sharing code with Gist



I am using gist for sharing code here. Credits to the original blogger's post.





How Do I Enable remote access to PostgreSQL database server?


This is a much discussed topic.
I will just quote links here  and here.

Note that if allowing the whole world to connect is desired. Append the following line

 host  all       all       0.0.0.0/0        md5  

Wednesday, March 5, 2014

Site matching query does not exist -- Django

Background: 

When migrating from sqlite3 to postgresql, after running

python manage.py syncdb

got error message “Site matching query does not exist.

The cause: 

Table django_site does not have any entry.

The fix: 

python manage.py shell
from django.contrib.sites.models import Site
Site.objects.all()
Site.objects.create(pk=1, domain='127.0.0.1:8000', name='localhost'

Credit : 
http://stackoverflow.com/questions/6957360/admin-login-stopped-functioning-django

Sunday, November 11, 2012

Gnuplot: how to draw histograms, the easy way

Suppose the test data is like


Num_clients S1 S2 S3 S4
1 6.853 6.812 6.811 6.813
2 10.726 10.701 10.699 10.7
3 15.122 15.101 15.099 15.1
4 21.761 21.699 21.695 21.696
5 28.254 28.231 28.233 28.232


We can plot a clustered histogram graph with the gnuplot script:

set terminal postscript eps enhanced 
set output 'test.eps'
set size 0.6,0.6
set yrange [1:50]
set xlabel "Num Mobile Clients (x10^5)"
set ylabel 'Server Workload (s)'

set xtics border nomirror
set ytics border nomirror

set style fill pattern
set style data histogram
set style histogram clustered gap 1

plot 'test.dat' u 2:xtic(1) title columnheader, \
'' u 3:xtic(1) title columnheader, \
'' u 4:xtic(1) title columnheader, \
'' u 5:xtic(1) title columnheader fs pattern 6



Wednesday, June 20, 2012

Latex: have two tables side by side?


\begin{table}
\parbox{.45\linewidth}{
\centering
\begin{tabular}{ccc}
\hline
a&b&c\\
\hline
\end{tabular}
\caption{Foo}
}
\hfill
\parbox{.45\linewidth}{
\centering
\begin{tabular}{ccc}
\hline
d&e&f\\
\hline
\end{tabular}
\caption{Bar}
}
\end{table}

Tuesday, April 10, 2012

Installing PostGIS 1.4.0 on Postgresql 8.4 on Ubuntu 10.04

http://www.paolocorti.net/2008/01/30/installing-postgis-on-ubuntu/


Install postgres 8.4
sudo apt-get install postgresql postgresql-client postgresql-contrib pgadmin3
Install postgis
sudo apt-get install libpostgis-java osm2pgsql postgresql-8.4-postgis
Create template
sudo su postgres
createdb postgistemplate
createlang plpgsql postgistemplate
psql -d postgistemplate -f /usr/share/postgresql/8.4/contrib/postgis.sql
psql -d postgistemplate -f /usr/share/postgresql/8.4/contrib/spatial_ref_sys.sql
Testing successful installation
psql -d postgistemplate -c "SELECT postgis_full_version();"

Monday, April 9, 2012

Fixing "font not embedded" issue to pass the IEEE PDF eXpress check

I spent two hours making my pdf file to pass the IEEE PDF eXpress check.


After I latex and submit the pdf file, I got the following errors.

Errors & Warnings
Severity Description
? 8 Error Font TimesNewRomanPSMT is not embedded (817x)
? 8 Error Font TimesNewRomanPS-ItalicMT is not embedded (204x)
? 8 Error Font TimesNewRomanPS-BoldItalicMT is not embedded (6x)
? 8 Error Font TimesNewRomanPS-BoldMT is not embedded (13x)
? 8 Error Font Arial-ItalicMT is not embedded
? 8 Error Font ArialMT is not embedded (12x)


You may also get other fonts embedding problem.


In Windows, the solution can be very simple.


1. open your pdf file, 
2. select file -> print
3. set your printer to be Adobe printer (assuming you already installed it)
4. click on properties
5. click the tab "Adobe PDF Settings"
6. uncheck "Rely on system fonts only; do not use document fonts"
7. click on the Edit... after Default Settings
8. click on Fonts, add those missing fonts to "Always Embed" (It is recommended to save the properties as a new setting.)
9. print the pdf file with the new settings, and your new pdf file should be good to go.