Compdigitec Labs

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 | 4 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 | 6 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 | 25 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 | 9 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 | 2 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 | 3 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 | 1 Comment »

Distributing small Java applications (i.e. convert to EXE)

By admin | April 30, 2011

Many times it can be said that it is not very friendly getting a .class file to run. Here is a better way to get them to run – it involves first converting it to an executable .jar and then optionally converting to an executable file on Windows.

Prerequisites:

Procedure:

Topics: Linux | 3 Comments »

Debugging comments on old posts in WordPress

By admin | March 7, 2011

Sometimes on a WordPress blog all comment entry points on old blog posts will stop working. This can be caused by a number of problems:

  1. Posts are set to expire. If you select the option “Automatically close comments on articles older than x days” under Settings->Discussion, then posts will automatically close comments after x days.
  2. Your blog is not set to enable commenting. Enable “Allow people to post comments on new articles” under Settings->Discussion.
  3. The specific post is not allowing comments. Edit the post in question and under the “Discussion” section ensure both “Allow comments” and “Allow trackbacks and pingbacks on this page” are both selected.

If the above three steps still do not help, then you can run the following database queries to enable comments globally:

UPDATE wp_posts SET comment_status = REPLACE (comment_status, 'closed', 'open') WHERE post_status = 'publish' AND post_type = 'post';
UPDATE wp_options SET option_value = 0 WHERE option_name = 'close_comments_for_old_posts'

Topics: PHP | 1 Comment »

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 »