Archives 2005 - 2019

Use a merge tool for all merges in Git

published Jun 27, 2013 02:21   by admin ( last modified Jun 27, 2013 02:21 )

A couple of days ago Git decided to automatically merge two branches through, among other things, switching method names between two method bodies (in python). The aggregate result was a mess.

For smaller projects there will not be massive changesets. Is there a way to tell Git to always use a merge tool, even the ones not deemed as a conflict by Git? There seems to be an answer on StackOverflow, define your own configuration version of kdiff3 with the --qall flag set. As I understand the tool always get the option to merge. Untested by me as of yet.

 

if you really want to disable any automatic resolving, just add --qall to the kdiff3 command line above. But then you have to manually resolve all changes in the file manually, even the ones that did not result in a git conflict.


Read more: Link - git - How could I force mergetool GUI (kdiff3) to be always shown? - Stack Overflow


Making a Plone 2.5.5 buildout as of now on Ubuntu 10.4

published Jun 25, 2013 10:55   by admin ( last modified Feb 20, 2015 02:18 )

Also check the newer post: Making a python 2.4 virtualenv buildout on Ubuntu 10.4 & Debian 7 as of 2014-03

I had to make a Plone 2.5.5 buildout today, in order to get the last Plone 2.5 web site of any of my customers up to the Plone 3/4 world. There was some trouble that did not happen half a year ago or so. Here's how to get around it.

Python 2.4

Is still in the repositories for Ubuntu 10.4 LTS. So no problem there. At least.

Virtualenv with site packages

If I used --no-site-packages then the subsequent steps to a functioning buildout would not work, specifically bootstrap.py would go into an infinite "installing distribute loop", so virtualenv must install a local python with access to the 2.4 site packages. Furthermore, with the --setuptools flag, --no-site-packages will make virtualenv (1.4.5) crash on my machine.

Setuptools must also be use instead of distribute. On the slightly older virtualenv I used (1.4.5), with site packages is the default, on newer ones no site packages is the default. So on my older version it's:

virtualenv --setuptools -p python2.4 .

On a newer virtualenv it would probably be:

virtualenv --setuptools --system-site-packages -p python2.4 .

Bootstrap.py with an older zc.buildout specified

With the bootstrap.py script, you can specify a version string

./bin/python bootstrap.py --version 1.4.4

This will give you zc.buildout 1.4.4, which is the recommended old version for those who have problems wth the new version.

Pin Pillow to an older version than current version

If you are using Pillow, the PIL replacement, it cannot be newer than 1.7.8, which is the recommended old version for python 2.4.

Pillow ==1.7.8

...if you pin it in the eggs section,

Pillow =1.7.8

...if you instead pin it in the versions section.

Remove zope libraries in system python2.4

see:

The Donkey's Stone: AttributeError: 'module' object has no attribute 'Surrogate'

 

 

 

 


Some notes on Webview on Android

published Jun 25, 2013 10:16   by admin ( last modified Jun 25, 2013 10:16 )

From the jquery mobile documentation:

 

Android enforces a timeout when loading URLs in a webview which may be too short for your needs. You can change this timeout by editing a Java class generated by the Eclipse plugin for Android:

super.setIntegerProperty("loadUrlTimeoutValue", 60000);

....

Try animation-fill-mode to reduce blinky transitions but beware that we're found that certain devices like the Nexus 7 run animations very slowly when this CSS property is in play. We recommend targeting this carefully and testing thoroughly to ensure that it doesn't impact smoothness. To see how to add this to your CSS, see this commit.


JQuery and Android 2.3, calling a url again gives the cached result

published Jun 23, 2013 03:59   by admin ( last modified Jun 23, 2013 03:59 )

Does a URL always give back the same result? Well according to the standard browser on Android 2.3 it does, at least when using jquery's get method.

I couldn't figure out why the Android 2.3 phone looped over the same old results eventhough the data URL for more new stuff was called anew. It worked well on the laptop and on the Android 4 tablet. It turns out that the 2.3 browser simply thinks that if a url has been called once from javascript, the result is going to be the same on subsequent calls. So it just gives back the old results.

Solution: Add a request number to a dummy request parameter called e.g. "foo":

http://server/more_new_stuff/session_id

becomes:

http://server/more_new_stuff/session_id?foo=1

and foo=2, foo=3, and so on.


Episodes - instrumenting the visitor's browser

published Jun 20, 2013 07:56   by admin ( last modified Jun 20, 2013 07:56 )

...so that you can monitor load times for page, regarding answer from server, time for libraries to load, and whole page.

 

Here are the episodes for this page:


Read more: Link - Episodes Example 1


Some databases

published Jun 20, 2013 02:45   by admin ( last modified Jun 20, 2013 03:16 )

Notes to self.

Tokutek


Tokutek is MongoDB but allegedly with better performance for indexing and some other stuff

The direct benefits include high-performance indexing, strong compression, and performance stability – in other words, the performance stays high, even when data is larger than RAM

 

Read more: Link - Better MongoDB Performance | Tokutek

Hyperleveldb - a faster version of leveldb

Inside HyperLevelDB :: Hacking, Distributed

Ardb

Ardb, uses Redis protocol for accessing some fast databases, mostly leveldb.

Ardb is a BSD licensed, redis-protocol compatible persistent storage server, it support different storage engines. Currently LevelDB/KyotoCabinet/LMDB are supported, but only LevelDB engine is well tested.
 

KDr2/redis

Another one that does the same for leveldb only:

KDr2/redis-leveldb · GitHub

 


What Apache means with "The time taken to serve the request"

published Jun 15, 2013 05:10   by admin ( last modified Jun 18, 2013 12:23 )

I take it in good faith that this guy knows what he's talking about.

 

%D logs the time between Apache starting to process a request (i.e. I believe it omits the handshake) and offloading it completely onto the local TCP stack.


Read more: Link - apache2 - The time taken to serve the request? - Server Fault


Get an element to stay fixed on scroll on the Android 2.3 browser

published Jun 14, 2013 02:31   by admin ( last modified Jun 14, 2013 02:31 )

The page must not be zoomable.

 <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
 

 



Read more: Link - html - How to disable web page zooming/scaling on Android? - Stack Overflow


How to use single quotes in a perl one-liner

published Jun 14, 2013 01:23   by admin ( last modified Jun 14, 2013 01:23 )

Use the octal form, i.e. \047 .

 

echo "a,b" | perl -F',' -lane 'print "$F[0]\047";' a'


Read more: Link - shell - Perl one-liner with single quote - Stack Overflow


Interrotron - a cool kind of teleprompter

published Jun 13, 2013 11:06   by admin ( last modified Jun 13, 2013 11:06 )

As far as I can tell from the explanation, it works a bit like mirrored sunglasses. On such sunglasses, from the inside you see the world accurately albeit darkly, and from the outside you just see a reflection. If you put a screen with the same properties but with the mirror at the user at say a 45 degree angle from horizontal in front of a camera lens, the subject can look at the camera lens while still seeing what is projected on the screen (say from beneath).

 

 

Errol Morris - Wikipedia, the free encyclopedia
 

Read more: Link - interrotron1.jpg (JPEG Image, 750 × 482 pixels)


Make collective.recipe.supervisor run scripts as if in another directory

published Jun 08, 2013 12:10   by admin ( last modified Jun 09, 2013 12:12 )

Summary, give the directory path without square brackets and without quotes.

At least that's what worked for me. In the documentation on pypi you read the following syntax:

priority process_name [(process_opts)] command [[args] [directory] [[redirect_stderr]] [user]]

It seems like the parameters both before the directory specification and the one behind, should be given in square brackets. Maybe that is why the directory specification should be given without. Maybe it is simply defined as anything between the brackets and hence also even accepts spaces, but have not tried that one. Bracketing it in double quotes did not work. Tested with the recipe pinned to version 0.17.

 

priority process_name [(process_opts)] command [[args] [directory] [[redirect_stderr]] [user]]


Read more: Link - collective.recipe.supervisor 0.19 : Python Package Index


Python debug tools

published Jun 08, 2013 01:57   by admin ( last modified Jun 08, 2013 01:57 )

A note to self.

 

This is an overview of tools I've used for debugging or profiling purposes. Not necessarily complete, if you know better tools, comment below.


Read more: Link - Python debugging tools | ionel's codelog


Ridiculously graphically well designed presentation on backbone.js

published Jun 07, 2013 02:58   by admin ( last modified Jun 07, 2013 02:58 )

The contents is probably good too, it seems to boil down to using marionette and decoupling into small units. I'm not into backbone.js right now so it's all I can say after a cursory look. But I can say that the graphical design and creativity of the slides are stunning.

 

Backbone.js is a popular, super lightweight JavaScript framework which helps you structure your code MVC style. If you're building JavaScript applications of any reasonable size, you might have heard of it and you might have even given it a try.


Read more: Link - Unsuck your backbone // Speaker Deck


Perl one-liners that gulp entire files for pattern matching

published Jun 05, 2013 06:40   by admin ( last modified Jun 05, 2013 06:40 )

Summary: instead of the -pi switch, enter -p0777i, and remember to use the ms modifier  in the regular expression.

 

Today I wanted to keep everything in each file, after a certain pattern, the last time that pattern was seen. One way of doing that is two write a perl one-liner that treats the file as one big long string, search and replace for the pattern and save away what is left.

The pattern for doing this is something like this:

find directory_name -name "*.txt" -print0|xargs -0 perl -p0777i -e  's!search_pat!replace_pat!gms;


...if you want to find all txt files under directory_name and replace search_pattern with replace_pattern, and do that:

  • many times if necessary (g)
  • over multiple lines (m),
  • expanding dot "." to also match newlines (s).
     
Now, the -0 flag in perl specifies (in octal) the input record separator (new lines in a text file). If we rely on the fact that no 0x777 character exists, we can swallow each file in one big gulp, and then do the search and replace over many lines. So:


Read more: Link - Search and replace across many files with a perl one-liner


ImageMagick from python

published Jun 04, 2013 11:24   by admin ( last modified Jun 04, 2013 11:24 )

Just a note to self:

 

Wand is a ctypes-based simple ImageMagick binding for Python.


Read more: Link - Wand — Wand 0.2.4


Switched from Unity to LXDE on Ubuntu 13.04 (Raring Ringtail)

published Jun 04, 2013 11:24   by admin ( last modified Jun 04, 2013 11:24 )

SInce upgrading to Ubuntu 13.04 from 12.04 and continuing running Unity on it, my laptop has become very sluggish. There is disk activity going on all the time, and it takes seconds for the computer to respond to the GUI.

The sluggishness isn't here all the time, but often enough for it to be a problem. A friend recommended me to try Unity 2D, but that does not exist as an option anymore on the newer Ubuntus. I have been trying to use htop to see where the problem is, both as root and as a normal user but I cannot seem to locate it. Firefox and Chrome feature prominently but I do not think both of them got buggy at the same time just because of a newer Ubuntu.

I have been looking at LXDE for some time as the GUI on virtual machines for my pupils and today I decided to switch to it on my own laptop. So far so good!

LXDE is isgnificantly less polished than e.g. Unity: Panels in LXDE overlap in the corners, sometimes the settings dialogs go bonkers, e.g. when picking applications in the Application Launch Bar. But so far disk activity has gone to virtually zero!

The "Lightweight X11 Desktop Environment" is an extremely fast-performing and energy-saving desktop environment.


Read more: Link - LXDE.org | Lightweight X11 Desktop Environment


How to make a temporary RAM disk on Linux

published May 22, 2013 12:40   by admin ( last modified Jun 05, 2013 07:17 )

Can be an interesting way to check if file accesses is killing a script's or application's performance. I have tested it and it can make things go blazingly fast. I have inserted about 8000 new record in an SQLite datbase from python, and the total speedup seems to be around a factor 20x -50x. Yes, of course it would be possible to solve this in another way, batching SQL inserts or having the db in-memory. But with a RAM disk I do not need to think about that.

 

$ mkdir /tmp/ramdisk; chmod 777 /tmp/ramdisk $ mount -t tmpfs -o size=256M tmpfs /tmp/ramdisk/


Read more: Link - axonxorz comments on SQLite Now Faster With Memory Mapped I/O

 


Dillinger - a markdown editor with a preview pane

published May 16, 2013 06:18   by admin ( last modified May 16, 2013 06:18 )

Looks neat.

 

Dillinger is a cloud-enabled HTML5 Markdown editor. Type some Markdown text in the left window See the HTML in the right Magic


Read more: Link - Online Markdown Editor - Dillinger, the Last Markdown Editor ever.


Link - Letting Generic Setup handle content types that may not exist

published May 15, 2013 04:47   by admin ( last modified May 15, 2013 04:47 )

Saw this today and just saving the link for reference if I would run into this problem.

 

Fortunately there is an undocumented feature hidden in GS: You can declare your type declaration as deprecated. This way, GS does not try to initialize the object and does not try to create the type information object if it does not exist.


Read more: Link - How to handle unknown meta_type in GS — Starzel.de


Analyze Apache log files from the command line

published May 14, 2013 03:00   by admin ( last modified May 15, 2013 04:48 )

Sometime you just want to get a quick overview of what's going on. In this case I wanted to know from what regions accesses were made to a specific page. This web article: Analyzing Apache Log Files < System | The Art of Web, showed how to use awk to filter out specific fields in the apache log format.

 

I found some info on how to geolocate from the command line here: Geolocate a given IP address | commandlinefu.com (I installed geoip-bin on my Debian).

 

The resulting one-liner, that

  • checks for a pattern in the log file vhosts_access.log,
  • extracts the ip number for each request
  • and geolocates it:

 

grep 'some_pattern_in_the_log' vhosts_access.log|awk '{print $2}'|sort|uniq| xargs -I xxx geoiplookup xxx|sort|less