Autarchy of the Private Cave

Tiny bits of bioinformatics, [web-]programming etc

    • Archives

    • Recent comments

    Archive for the 'Programming' Category

    Drupal theme development: where to start

    8th June 2008

    Simplest way to develop your custom Drupal theme is to start with some skeleton/wireframe theme.

    In this post, I’m briefly reviewing 4 themes (atck, blueprint, framework, and zen), made specifically to serve as theme developer’s starting point. All 4 are listed with their features (as per Drupal project page of each one), with my personal “impressions” (not based on actual use experience, yet). There’s also my choice and order of preference for the 4 candidates at the end.
    Read the rest of this entry »

    Share

    Posted in Drupal, Links, Notepad, Software, Web, XHTML/CSS | 8 Comments »

    Ad Unit Guidelines

    7th June 2008

    When either consulting on a new website design, or actually designing one, keep in mind Ad Unit Guidelines if the website is going to use advertising. The list is far not exhaustive, but sufficiently standard.

    Share

    Posted in Links, Notepad, Web, XHTML/CSS | No Comments »

    Developing reluctant (pessimal) algorithms

    13th April 2008

    If you had some programming experience – read it here. Otherwise ignore, it’s targeted for a narrow group.

    Share

    Posted in Humour, Links, Programming | No Comments »

    Instructions on installing libmp3lame-enabled ffmpeg on shared linux hosting

    12th March 2008

    Note: this post is based on the comment by Simon, who generously shared his experience.

    Step-by-step:

    • Download the compiled ffmpeg with libmp3lame support (direct download links: older version ffmpeg.with.lame and newer version ffmpeg.2007-10-28.with-libmp3lame-support).
    • Rename the downloaded executable file to “ffmpeg” (no extension), upload it to the directory on your server (in this example /home/myusername/).
    • Download libmp3lame.so.0.
    • Upload libmp3lame.so.0 to the same directory where you placed ffmpeg in.
    • Create a php file with the following code (remember to change the paths to your own, where you actually uploaded binaries in previous steps):
      1. <?php
      2. exec("export LD_LIBRARY_PATH=/home/myusername/");
      3. echo passthru("/home/myusername/ffmpeg -formats");
      4. ?>
    • If you access that PHP file with your browser, you should be able to see a list of formats which are supported by ffmpeg, and if you find “EA libmp3lame” somewhere in the output, then it means you now can Encode Audio in libmp3lame!
    • If that doesn’t work for you: LD_LIBRARY_PATH can be a protected variable in PHP (you can check for this by searching for the “safe_mode_protected_env_vars” value in phpinfo() output). The workaround here can be to write your commands to a file from php, then chmod that file with 0755 permissions (rwx-rx-rx), and run the file through exec(). In this way, PHP is not changing the LD_LIBRARY_PATH, but telling the server to run a file, which tells the server to change it. This method worked for the original author of these instructions.

    For passing arguments to the PHP wrapper script – check out PHP’s $argv variable (more on this here). If you decided to use shell-script as a wrapper for “export LD_LIBRARY_PATH”, then using $1, $2 etc will allow you to pass parameters to the shell script, e.g. in the example below

    1. #!/bin/bash
    2. export LD_LIBRARY_PATH=/home/myusername/
    3. /home/myusername/ffmpeg -i /home/myusername/$1 $2 /home/myusername/$3

    you could pass “input file” as first argument, “parameters” as second and “output file” as third to make such a wrapper script work.

    Share

    Posted in *nix, PHP, Programming, Software, Web | 19 Comments »

    How to improve MySQL application performance

    6th March 2008

    Juicy presentation, even for seasoned MySQL developers.

    SlideShare | View

    Read the rest of this entry »

    Share

    Posted in Links, Programming, Web | No Comments »

    SQL injection: RIAA example

    16th February 2008

    I know it’s kind of old now, but check this image out:

    RIAA screenshot with some SQL injection code

    Via webplanet.ru – reddit.com.

    Share

    Posted in Links, Notepad, Programming, Society, Web | No Comments »

    Python: passing by value vs passing by reference

    11th February 2008

    Note: this a collection of scraps, describing how values (de)referencing works in Python, and describing when your variable is either a value or a reference. Primary source of knowledge for this post (also here).

    Python passes references-to-objects by value (like Java), and everything in Python is an object. This sounds simple, but then you will notice that some data types seem to exhibit pass-by-value characteristics, while others seem to act like pass-by-reference… what’s the deal?

    It is important to understand mutable and immutable objects. Some objects, like strings, tuples, and numbers, are immutable. Altering them inside a function/method will create a new instance and the original instance outside the function/method is not changed. Other objects, like lists and dictionaries are mutable, which means you can change the object in-place. Therefore, altering an object inside a function/method will also change the original object outside.

    Immutable variables – such as integers [strings, numerics and tuples are immutables] – are passed by value. That is, if your function accepts some integer argument, you are safe assuming that your function won’t be able to modify your integer. Mutable variables – such as dictionaries and lists – are passed by reference, and so if your function accepts mutable argument, it may modify the contents of that mutable variable outside the scope of the function.

    When doing :
    s = “Hello ”
    s += “World”
    … you are not modifying the string object bound to s, but creating a new string object and binding it to s.

    If using object’s methods within a called function, variable is considered “passed by reference” – it is modified out of the function’s scope. If using assignment on a mutable object, it is created a-new within the function, and global value isn’t modified.

    When you call a function with an arg, a “local variable” is created, which references the object passed as the argument. (well… an entry with the formal parameter name as key and a reference to the object passed in is created in the ‘local’ dict).

    So, rebinding this local symbol does not impact the binding in the caller’s namespace – because the symbol lives in another namespace.

    *But* – and if the object referenced is mutable of course – modifying the object in the function… well, just modifies the object, because it’s the *same* object that is bound to (‘referenced by’, if you prefer) both symbols (the one in the caller’s namespace and the one in the function’s namespace). So yes, the object *is* modified when the function returns.

    Share

    Posted in Links, Programming, Python | 3 Comments »