Projects


content
July 26, 2010: 2:28 pmterms: LokkjuProjects

HTSQL is a very cool open source product that gives you a RESTful interface to multiple database backends. Because it uses it’s own simple, but very powerful, syntax, you avoid most of the risks involved in passing in SQL. Currently it supports SQLite and PostgreSQL, but for my current project, I need to support Geometry columns.

For the first draft, I just wanted to add support for Spatialite, a spatially enabled version of SQLite. Since SQLite is already supported, this turned out to be relatively easy – though in hindsight, I may not even have implemented it in the easiest way possible – but I’ll get to that in another post.

So, each database backend is in a namespace called htsql_[name], and they all subclass files in the main htsql namespace. I started off by cloning the htsql_sqlite tree into a new namespace called htsql_spatialite, and ripped out most of the code, leaving me with a basic structure. I then subclassed any SQLite classes I wanted to override – most importantly:

  1. Changed connect.py to import pyspatialite instead of pysqlite2.
  2. Added my own Column and Data types (Domains) in domain.py
  3. Modified introspect.py to handle my custom Domains, as well as to handle the blank Column type sometimes given for Geometry columns

I also, and here is where most of my functionality was added, overrode a few classes in tr/serializer.py:

  1. Class SpatialiteSerializeLeafReference(subclassing SerializeLeafReference) tests if I am selecting a Geometry column, and if I am, wraps it in the “AsText” function, to return WKT.
  2. a new Adaptor, FormatGeometry, which handled the representation of the WKT when returned to the client. Right now, only HTML is supported, but JSON, CSV, and the rest are easy to add in the same way.

The last thing you have to do is add a line in setup.py to point to your new database engine’s entry point – it is in a list called ENTRY_POINTS.

Interestingly, I think I could better utilize the plugin architecture – but as I’m just discovering HTSQL, and there isn’t all that many samples, nor much documentation, I’m pretty happy with what I accomplished.

You can see the full source of my additions at https://bitbucket.org/lokkju/htsql-appengine/src/3d7b7d8e8580/

trademarks
May 1, 2010: 10:30 pm: LokkjuProjects

I found that getting the template database for postgis set up was somewhat poorly documented – so:

First, create a role that will own the tables within the template database:
psql -c "CREATE ROLE gisgroup;"

Second, create and populate the template database:

createdb -E UNICODE template_postgis
createlang -d template_postgis plpgsql
psql -d template_postgis < /usr/share/postgresql/8.4/contrib/postgis-1.5/postgis.sql
psql -d template_postgis < /usr/share/postgresql/8.4/contrib/postgis-1.5/spatial_ref_sys.sql
psql -d template_postgis < /usr/share/postgresql/8.4/contrib/postgis_comments.sql

Third, set the ownership to the role you created:

psql -c "ALTER TABLE geometry_columns OWNER TO gisgroup;" template_postgis
psql -c "ALTER TABLE spatial_ref_sys OWNER TO gisgroup;" template_postgis

Fourth, we create the user for our database:

psql -c "CREATE USER yourgisuser WITH PASSWORD 'yourpassword';"
psql -c "GRANT gisgroup TO yourgisuser;"

Fifth, and last, we create a new postgis enable database:
createdb -T template_postgis -O yourgisuser your_new_postgis_database

service
April 29, 2010: 10:51 am: LokkjuC#, Projects

Though there are a lot of articles out there on office automation in dotnet (most of them telling you not to do it), there are very few covering how to get office automation up and running under IIS7 on a 64bit machine – and it is possible.

I needed to do this recently, and found one hint on how to get it working at http://forums.asp.net/t/1328690.aspx . They key is to use Process to launch the application you need, then attach to it.

Sample code in C#:


Microsoft.Office.Interop.Word.Application app = null;
Process proc = null;
Document doc = null;
try
{
ProcessStartInfo procinfo = new ProcessStartInfo(WORD_PATH, "");
procinfo.WorkingDirectory = AppDomain.CurrentDomain.BaseDirectory;
procinfo.CreateNoWindow = true;
procinfo.WindowStyle = ProcessWindowStyle.Hidden;
proc = Process.Start(procinfo);
proc.WaitForInputIdle();
app = (Microsoft.Office.Interop.Word.Application)System.Runtime.InteropServices.Marshal.GetActiveObject("Word.Application");
if (app == null) { throw new Exception("Word not found"); }
app.Visible = false;
app.DisplayAlerts = WdAlertLevel.wdAlertsNone;
#region Declare Params
object fileName = filename;
object ConfirmConversions = false;
object ReadOnly = true;
object AddToRecentFiles = Type.Missing;
object PasswordDocument = Type.Missing;
object PasswordTemplate = Type.Missing;
object Revert = Type.Missing;
object WritePasswordDocument = Type.Missing;
object WritePasswordTemplate = Type.Missing;
object Format = Type.Missing;
object Encoding = Type.Missing;
object Visible = false;
object OpenAndRepair = Type.Missing;
object DocumentDirection = Type.Missing;
object NoEncodingDialog = Type.Missing;
object XMLTransform = Type.Missing;
#endregion
doc = app.Documents.Open(ref fileName, ref ConfirmConversions, ref ReadOnly, ref AddToRecentFiles, ref PasswordDocument, ref PasswordTemplate, ref Revert, ref WritePasswordDocument, ref WritePasswordTemplate, ref Format, ref Encoding, ref Visible, ref OpenAndRepair, ref DocumentDirection, ref NoEncodingDialog, ref XMLTransform);
// DO WHATEVER YOU NEED TO HERE
}
finally
{
object saveChanges = WdSaveOptions.wdDoNotSaveChanges;
object OriginalFormat = Type.Missing;
object RouteDocument = Type.Missing;
try
{
((_Document)doc).Close(ref saveChanges, ref OriginalFormat, ref RouteDocument);
doc = null;
}
catch { }
try
{
((Microsoft.Office.Interop.Word._Application)app).Quit(ref saveChanges, ref OriginalFormat, ref RouteDocument);
app = null;
}
catch { }
try
{
proc.Kill();
}
catch { }
}

store
about
September 17, 2008: 7:45 am: LokkjuCrazyness, Projects

If you are using VMWare Fusion under OS X 10.5 (Leopard) with bootcamp, and get an “Error loaded operating system message”, there is finally a simple fix.
Open your *.vmx file for your virtual machine, and add the following line:

ide0:0.biosGeometry=”1024/255/63″

that should do the magic!

content
June 5, 2008: 8:10 amterms: LokkjuProjects

Thanks to Quintin at junkmail.co.za, dnsEditor now supports Batch adding of zones, zone defaults, and some extra configuration options.

Changes:
- Now has “Click to Edit” instead of empty fields
- Configuration option to hide the “update servers” button
- Batch add zones
- Zone field defaults, for multiple or single A, MX, CNAME, TXT, etc records to be created automatically in a new zone

Demo:
http://www.lokkju.com/projects/dnsEditor2/dnsEditor.php

Source:
http://svn.lokkju.com/svn/dnsEditor/trunk

trademarks
September 10, 2007: 8:04 am: LokkjuObj-C, Projects, iphone

pumpkin and I – of iphone-wireless – have coded up the first Stumbler application for the iPhone. If you want to check it out, visit us at http://iphone-wireless.googlecode.com.

Screenshots:

Stumbler Screenshot 1
Stumbler Screenshot 2

service
August 26, 2007: 6:16 am: LokkjuC#, Projects

UPDATE:
new google code project page at http://code.google.com/p/iphonefs/

Ok, just got done with getting this to the point it mostly works.
Files are at http://projects.lokkju.com/iPhoneDrive.1.0.2794.12283.zip

Simple instructions:
unzip, run iPhoneDriveControl.exe.
A messagebox will pop up, asking for the location of iTunesMobileDevice.
Select the file, hit ok.
The program will start.
Ignore all the german scrolling in the trace window – the is alpha goddammit.
When it runs, it will find the next available drive letter.
The drive letter will be printed to the Trace window.
The drive letter will be mapped to the phone’s filesystem.
Now you can use Windows Explorer or the command line, makes no diff.

Feel free to submit bugs, but I know there are lots, it is an alpha.

Also, this works just fine on unhacked phones, it will just show your jail root.

For windows obviously, though it might be ported to linux under mono.

If anyone wants to work on the source with me, and knows C#, let me know through comments or email.
I have a svn repo, and you can submit patches or I can give access.

Right now this is semi closed source, but should eventually be released under the GPLv3.
Specifically the CIFS server implementation is not open source yet, and isn’t mine, though the auther keeps saying he might make open source soon.

Once I get the bugs worked out, it will run as a windows service, so you have the drive whenever you plug in your iPhone.

store
about
July 28, 2007: 2:03 pm: LokkjuJavascript, Projects

I wrote a couple of quick jQuery plugins over the last few days.

First is jqFrag, an implementation of the fragment uri scheme that allows jumping to a specific instance of word in a document, by using uri://site/page?query#@ syntax. Example and code:
http://projects.lokkju.com/jquery/jqfrag/index.html#@rutrum

Second is jqProps, a var_dump/Dumper implemtation for javascript – essentially, it will let you see all the properties (fields, methods, etc) of anything you pass it. Code at:
http://projects.lokkju.com/jquery/jqdumper/jquery.dumper.js

Comments welcome

content
June 22, 2007: 3:30 pmterms: LokkjuJavascript, Projects

Changes:
– broke configuration out to config.php
– included the ability to log errors
– added TXT records
– added CNAME records
– forced all zones to lower case
– forced all types to upper case
– changed serial format
– zone list refreshes when new zone is added
thanks to Valery Duchev for some patches

Demo:
http://www.lokkju.com/projects/dnsEditor2/dnsEditor.php

Source:
https://svn.lokkju.com/svn/dnsEditor/trunk

trademarks
May 16, 2007: 7:24 am: LokkjuC#, Projects

Something you see all the time in Javascript is using the flash and fade of the background color of an object to indicate some form of activity – success, error, etc. There is nothing that makes this easy in C#, but I managed to do it using some hacky Invoke calls.
Code is after the break, but you can download the entire test project: ColorAnim Test Project (VS2005)

(more…)

Next Page »

service
Make payments with PayPal - it's fast, free and secure!
store
about