Compdigitec Labs

VLC pre-alpha for Android 2.1 – Jan 2, 2012

By admin | January 2, 2012

Will post a how-to compile guide later, just wanted to upload the binaries that I am working on through GCI for purpose of testing, along with screenshots. If in doubt, download the first one (VLC-debug.apk).

Screenshots

Topics: Mobile | 12 Comments »

Operating systems and car dealerships

By admin | November 4, 2011

An excerpt from the essay In the Beginning was the Command Line (CC BY-SA 2.0) by Michael Foord.

The analogy between cars and operating systems is not half bad, and so let me run with it for a moment, as a way of giving an executive summary of our situation today.

Imagine a crossroads where four competing auto dealerships are situated. One of them (Microsoft) is much, much bigger than the others. It started out years ago selling three-speed bicycles (MS-DOS); these were not perfect, but they worked, and when they broke you could easily fix them.

There was a competing bicycle dealership next door (Apple) that one day began selling motorized vehicles–expensive but attractively styled cars with their innards hermetically sealed, so that how they worked was something of a mystery.

The big dealership responded by rushing a moped upgrade kit (the original Windows) onto the market. This was a Rube Goldberg contraption that, when bolted onto a three-speed bicycle, enabled it to keep up, just barely, with Apple-cars. The users had to wear goggles and were always picking bugs out of their teeth while Apple owners sped along in hermetically sealed comfort, sneering out the windows. But the Micro-mopeds were cheap, and easy to fix compared with the Apple-cars, and their market share waxed.

Eventually the big dealership came out with a full-fledged car: a colossal station wagon (Windows 95). It had all the aesthetic appeal of a Soviet worker housing block, it leaked oil and blew gaskets, and it was an enormous success. A little later, they also came out with a hulking off-road vehicle intended for industrial users (Windows NT) which was no more beautiful than the station wagon, and only a little more reliable.

Since then there has been a lot of noise and shouting, but little has changed. The smaller dealership continues to sell sleek Euro-styled sedans and to spend a lot of money on advertising campaigns. They have had GOING OUT OF BUSINESS! signs taped up in their windows for so long that they have gotten all yellow and curly. The big one keeps making bigger and bigger station wagons and ORVs.

On the other side of the road are two competitors that have come along more recently.

One of them (Be, Inc.) is selling fully operational Batmobiles (the BeOS). They are more beautiful and stylish even than the Euro-sedans, better designed, more technologically advanced, and at least as reliable as anything else on the market–and yet cheaper than the others.

With one exception, that is: Linux, which is right next door, and which is not a business at all. It’s a bunch of RVs, yurts, tepees, and geodesic domes set up in a field and organized by consensus. The people who live there are making tanks. These are not old-fashioned, cast-iron Soviet tanks; these are more like the M1 tanks of the U.S. Army, made of space-age materials and jammed with sophisticated technology from one end to the other. But they are better than Army tanks. They’ve been modified in such a way that they never, ever break down, are light and manoeuvrable enough to use on ordinary streets, and use no more fuel than a subcompact car. These tanks are being cranked out, on the spot, at a terrific pace, and a vast number of them are lined up along the edge of the road with keys in the ignition. Anyone who wants [one] can simply climb into one and drive it away for free.

Customers come to this crossroads in throngs, day and night. Ninety percent of them go straight to the biggest dealership and buy station wagons or off-road vehicles. They do not even look at the other dealerships.

Of the remaining ten percent, most go and buy a sleek Euro-sedan, pausing only to turn up their noses at the philistines going to buy the station wagons and ORVs. If they even notice the people on the opposite side of the road, selling the cheaper, technically superior vehicles, these customers deride them cranks and half-wits.

The Batmobile outlet sells a few vehicles to the occasional car nut who wants a second vehicle to go with his station wagon, but seems to accept, at least for now, that it’s a fringe player.

The group giving away the free tanks only stays alive because it is staffed by volunteers, who are lined up at the edge of the street with bullhorns, trying to draw customers’ attention to this incredible situation. A typical conversation goes something like this:

Hacker with bullhorn: “Save your money! Accept one of our free tanks! It is invulnerable, and can drive across rocks and swamps at ninety miles an hour while getting a hundred miles to the gallon!”

Prospective station wagon buyer: “I know what you say is true…but…er…I don’t know how to maintain a tank!”

Bullhorn: “You don’t know how to maintain a station wagon either!”

Buyer: “But this dealership has mechanics on staff. If something goes wrong with my station wagon, I can take a day off work, bring it here, and pay them to work on it while I sit in the waiting room for hours, listening to elevator music.”

Bullhorn: “But if you accept one of our free tanks we will send volunteers to your house to fix it for free while you sleep!”

Buyer: “Stay away from my house, you freak!”

Bullhorn: “But…”

Buyer: “Can’t you see that everyone is buying station wagons?”

Topics: Linux | 12 Comments »

Geany 0.21 Debian pacakge for Ubuntu/Debian

By admin | October 25, 2011

The version of Geany provided with the repository in Ubuntu is a bit outdated (0.18) by two years, so we have also decided to produce an updated version (0.21) for use on Ubuntu 10.04 LTS and other versions of Ubuntu.
Download

Compiling

./configure --enable-binreloc --enable-socket --enable-vte --enable-the-force --prefix=/usr
make
make install

Topics: Linux | 7 Comments »

Updated version of YASM v1.1.0 for Ubuntu

By admin | October 24, 2011

The version of YASM provided with Ubuntu 10.04 is a bit outdated (0.8, updated in 2009) and is not sufficient enough to compile Mozilla Firefox. Therefore we have decided to compile an updated package of YASM v1.1.0 instead.

Download

Compile your own copy
wget http://www.tortall.net/projects/yasm/releases/yasm-1.1.0.tar.gz -O- | tar zxvf -
cd yasm-1.1.0
./configure --disable-nls --prefix=/usr
make
make install
yasm --version
#yasm 1.1.0.2352
#Compiled on Oct 23 2011.
#Copyright (c) 2001-2010 Peter Johnson and other Yasm developers.
#Run yasm --license for licensing overview and summary.

Topics: Linux | 1 Comment »

Adding custom profile fields in WordPress (fully automatic)

By admin | October 17, 2011

Custom profile fields are additional custom-defined fields in the WordPress usermeta database that permit us to store additional information about a user. To add custom profile fields, add the following line to your functions.php in your theme folder:

include('customfields.php');

Now create a new file called customfields.php in the theme folder (the same folder as function.php) with the following contents:

<?php

function get_extra_profile_list() {
return Array(
/* Add your custom fields, here like follows:
'slug_of_the_field_here' => 'Field name for display',
 */
'address' => 'Address',
'favouritecolour' => 'Favourite Colour'
);
}

add_action( 'show_user_profile', 'extra_user_profile_fields' );
add_action( 'edit_user_profile', 'extra_user_profile_fields' );

function extra_user_profile_fields( $user ) { ?>
<h3><?php _e("Extra profile information", "blank"); ?></h3>

<table class="form-table">
<?php
foreach(get_extra_profile_list() as $key => $value) {
?>
<tr>
<th><label for="<?php echo $key; ?>"><?php _e($value); ?></label></th>
<td>
<input type="text" name="<?php echo $key; ?>" id="<?php echo $key; ?>" value="<?php echo esc_attr( get_the_author_meta( $key, $user->ID ) ); ?>" class="regular-text" /><br />
<span class="description"><?php _e("Please enter your $value."); ?></span>
</td>
</tr>
<?php
}
?>
</table>
<?php }

add_action( 'personal_options_update', 'save_extra_user_profile_fields' );
add_action( 'edit_user_profile_update', 'save_extra_user_profile_fields' );

function save_extra_user_profile_fields( $user_id ) {

if ( !current_user_can( 'edit_user', $user_id ) ) { return false; }

foreach(get_extra_profile_list() as $key => $value) {
update_usermeta( $user_id, $key, $_POST[$key] );
}
}
?>

Now if you go to “Users” under your administration and edit a user, the additional profile fields will show up at the bottom of the edit page.

Topics: PHP | 9 Comments »

WP No-bot Question plugin for WordPress

By admin | October 9, 2011

Most spam on your WordPress blog is caused by automated robots (spambots) which keep submitting to your comment form to inflate some shady website’s rank. Short of completely disabling or turning on blog moderation and wasting your time filtering through the mess, you can now use the new WP No-bot Question plugin developed by Compdigitec for WordPress – simply activate, set your question and answers and block all the spam bots! Best used in conjunction with other spam and server protection plugins such as NoSpamNX and Bad Behaviour. This plugin was inspired by the Anti-Bot Question Mod for phpBB, which is very effective against spambot user registration on phpBB.

See the plugin page on Compdigitec for more details and screenshots/downloads.

Topics: PHP | 28 Comments »

Compiling GNU Bash 4.x for Android 2.x

By admin | September 4, 2011

Updated (2012-02-04): Updated to Bash 4.2 and included source code used to compile.

GNU Bash (the GNU Bourne Again Shell) is the standard shell on most desktop and server distributions of Linux. As a result, we can download bash source code and compile the Bash shell for use on Android devices to replace default /bin/sh and busybox sh. Since the Android NDK doesn’t support the full glibc library (it lacks /etc/group and friends), a small patch is required to compile Bash for Android 2.x devices (probably caused by changes since Android 1.5.x).

If you don’t feel like compiling from scratch you can download a pre-built version.

Prerequisites

Once your prerequisites are set up and functioning properly (adjust all paths as required, such as ndk path):

export ANDROID_NDK=/opt/android-ndk-r7
export CC="${ANDROID_NDK}/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/arm-linux-androideabi-gcc --sysroot=${ANDROID_NDK}/platforms/android-5/arch-arm/"
patch -p0 < bash-android.patch
./configure --host=arm-linux --enable-static-link --without-bash-malloc --disable-rpath --disable-nls

Once that is done, open Makefile and add -static to CFLAGS so it looks like so: “-g -O2 -static”

make
file bash
# bash: ELF 32-bit LSB executable, ARM, version 1 (SYSV), statically linked, not stripped

You will find bash sitting in the folder. Now you can deploy it and try it through adb or something similar:

adb push bash /data/local/bin/bash
adb -d shell
$ /data/local/bin/bash
bash-4.2$ /data/local/bin/bash --version
GNU bash, version 4.2.0(2)-release (arm-unknown-linux-gnu)
Copyright (C) 2011 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>

This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
bash-4.2$

Of course, once you have it ready and set up you should probably create a “.bashrc” file to make the terminal a bit more bearable, if you wish to.

Bash running on Android 2.x

Topics: Mobile | 11 Comments »

Creating jQuery UI Tabs

By admin | August 21, 2011

jQuery UI Tabs are an easy way to make tabs in your web applications or web sites easily with less code. Consider the following tab structure:

<div id="tabgroup">
	<ul>
		<li><a href="#tab1">Tab 1</a></li>
		<li><a href="#tab2">Tab 2</a></li>
		<li><a href="#tab3">More Tabs</a></li>
	</ul>
	<div id="tab1">Hello</div>
	<div id="tab2">World</div>
	<div id="tab3">from jQuery UI Tabs</div>
</div>

To turn this into a fully featured functioning tab system, all one has to execute in the <head> is this provided you have included jQuery and jQuery UI with any CSS in your <head> (default CSS can be included like such: <link rel=”stylesheet” type=”text/css” href=”http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.9/themes/ui-lightness/jquery-ui.css” />):

jQuery(document).ready(function() {
	jQuery("#tabgroup").tabs();
});

This tab structure also degrades reasonably without JavaScript – one is able to view the contents of all of the tabs and the anchor links are usable – unlike some other tab techniques.

Topics: (X)HTML | 7 Comments »

Light build of Mozilla Firefox

By admin | June 30, 2011

Most of the time, a stock Firefox installation from Mozilla’s website or the apt repository usually works just fine on most machines. However, if you prefer a more plain and vanilla Firefox install without all the latest bells and whistles, then one can manually compile a build from source code. This has the advantage of being faster and leaner than the stock Firefox because the unwanted features are simply not present, although you will not have all the latest web bells/whistles with this method (e.g. WebM, WebGL, HTML5 video, etc).

Download a copy of the Firefox source, and extract it. Then run ./configure as follows:

–enable-application=browser –enable-official-branding –disable-debug –with-x –disable-profiling –disable-gnomevfs –disable-gconf –disable-accessibility –disable-ogg –disable-webm –enable-splashscreen –disable-angle –enable-crashreporter –disable-smil –disable-installer –disable-updater –disable-update-packaging –disable-parental-controls –disable-tests –enable-faststart –disable-safe-browsing –disable-meegocontentaction –enable-optimize=-O2 –disable-logging –enable-install-strip –disable-necko-wifi –disable-glibtest

A few points to note:

Then run make. If you want to test your build, you can find it under dist/bin of your extracted tarball. Change to that directory and then one can test it like so:

LD_LIBRARY_PATH=. ./firefox-bin -ProfileManager -no-remote

This will allow you to test without clobbering your existing profile. When you are done, you can run make install (beware of conflicts with the repository’s firefox) or if you would rather use checkinstall to make a package, checkinstall –fstrans=no.

Topics: Linux | 9 Comments »

Launch non-exe extension files as executables

By admin | May 1, 2011

Windows does not come with a built-in way of launching executables that are without the exe extension. However, we have written a small tool called “anylaunch” which allows one to execute any file as if it were an executable. (Non-PE files will still give an error since they are not executables “XYZ is not a valid Win32 application”)

Download (anylaunch.exe) or compile from source below:

#include <iostream>
#include <windows.h>
#include <cstdlib>
//#define ZeroMemory(p,size) memset((p),0,(size))
using namespace std;

int main(int argc, char* argv[])
{
	if(argc-1 < 1) {
		cout << "No process specified" << endl;
		return 0;
	}
	
	STARTUPINFO si;
	PROCESS_INFORMATION pi;
	// must blank it
	memset(&si,0,sizeof(si));
	si.cb = sizeof(si);
	si.lpReserved = NULL;
	si.lpTitle = NULL;
	// required for GUI app
	si.dwFlags = STARTF_USESHOWWINDOW;
	si.wShowWindow = SW_MINIMIZE;
	
	bool res = CreateProcess(NULL,argv[1],NULL,NULL,FALSE,0,NULL,NULL,&si,&pi);
	if(res == false) {
		printf("CreateProcess failed (error code %d)\n", GetLastError());
		return 1;
	}

	CloseHandle(pi.hProcess);
	CloseHandle(pi.hThread);	
	return 0;
}

Download or compile the anylaunch executable and put it into the same directory as your script or into the system directory. You can use it in a command line, batch scripting or another program like so:
anylaunch “<process command line here>”

Simple examples (assuming anylaunch is in system path or current folder):

Although the biggest use of this tool is to launch non-exe PE files, like so:

file yes.123

yes.123: PE32 executable for MS Windows (GUI) Intel 80386 32-bit
Then we can use anylaunch to launch this PE file:

anylaunch yes.123
Non-exe process in Task Manager

Non-exe process in Task Manager

You may run into some problems while running this. If your command line arguments to your target application are not showing up, you should put your entire command line into one argument and escaping quotes (anylaunch “C:\\Program Files\\Mozilla Firefox\\firefox.exe” not anylaunch C:\Program Files\Mozilla Firefox\firefox.exe). Some other common problems:

Accessing a file that does not exist or is inaccessible (The system cannot find the file specified.):

cat somefile.rnd

cat: somefile.rnd: No such file or directory

anylaunch somefile.rnd

CreateProcess failed (error code 2)

Trying to run an invalid Windows application

file Untitled.png

Untitled.png: PNG image, 800 x 600, 8-bit/color RGB, non-interlaced

anylaunch.exe Untitled.png

CreateProcess failed (error code 11) (An attempt was made to load a program with an incorrect format.)
CreateProcess failed (error code 193) (%1 is not a valid Win32 application.)
etc… (invalid format error, or win32 errors, etc)

Topics: Windows | 6 Comments »

If you found this article helpful or interesting, please help Compdigitec spread the word. Don’t forget to subscribe to Compdigitec Labs for more useful and interesting articles! « Older Entries Newer Entries »