Howlingwolf

// More or less up to date despite of multiple authors ;)

Middle touchpad key for scrolling

Taken from here

How to make your middle touchpad-button act as a mousewheel:

Install the package gpointing-device-settings, call it via gpointing-device-settings on the bash.

check "Use middle button emulation"
check "Use wheel emulation"
select button "2"
check "Enable vertical scroll"
GPointing Device Settings_453

Temporarily change DRBD sync rate

How to temporarily change the sync rate for a DRBD-device?

drbdsetup /dev/drbd0 syncer -r 40M

Chosen Multiselect + STRG jQuery

Ich bin über einen kleinen Fehler im jQuery Plugin Chosen gestoßen.

Der Programmierer hat vorgesehen das ein umgewandelter Multiselect die möglichkeit hat mit haltender STRG tast sich das menü nicht schließt und somit sehr schnell viele auswahlen getroffen werden könne.

Leider ist es so das in der jQuery version einen kleinen definitionsfehler gibt der dafür sorgt das User die Chosen in verbindung mit jQuery 1.7.0 oder höher diese Funktion nicht nutzen können. laut Bug Tracker von Github ist dieser fehler bereits schon mehrere Monate bekannt und wurde bereits von einigen leuten bestätigt doch leider noch nicht behoben. Deswegen habe ich mich entschieden die Behebung hier kurz auszuführen.

chosen.jquery.js Version 0.9.8

Zeile 753:

if (!(evt.metaKey && this.is_multiple)) this.results_hide()

Ändern in

if (!(evt.ctrlKey && this.is_multiple)) this.results_hide();

Nach dieser änderung erkennt nun auch jQuery ab version 1.7.0 das Ihr den STRG oder im englischen ctrl (control) Key drückt und schließt die auswahl nun nicht beim klick

Iomega rescue data

A customer of mine had a problem with his Iomega ix2-200 “Storage Cloud”, for some reason it wouldn’t power up and he asked me to rescue (backup) the data from the harddrives.

To mount and get access to the data I put the harddrives to an external hdd-case and plugged it in via usb.

In the first step you have to find out where the drive is, e.g. after pluggin the usb in you can do a quick dmesg

dmesg  | grep sdb
[    3.722454] sd 6:0:0:0: [sdb] 3907029168 512-byte logical blocks: (2.00 TB/1.81 TiB)
[    3.723194] sd 6:0:0:0: [sdb] Write Protect is off
[    3.723202] sd 6:0:0:0: [sdb] Mode Sense: 00 38 00 00
[    3.723944] sd 6:0:0:0: [sdb] Asking for cache data failed
[    3.723950] sd 6:0:0:0: [sdb] Assuming drive cache: write through
[    3.726191] sd 6:0:0:0: [sdb] Asking for cache data failed
[    3.726197] sd 6:0:0:0: [sdb] Assuming drive cache: write through
[    3.758975]  sdb: sdb1 sdb2
[    3.761610] sd 6:0:0:0: [sdb] Asking for cache data failed
[    3.761617] sd 6:0:0:0: [sdb] Assuming drive cache: write through
[    3.761622] sd 6:0:0:0: [sdb] Attached SCSI disk

You can see there that the drive is attached as /dev/sdb. Iomega uses the first partition to store its system, so the data you are searching for are most likely within /dev/sdb2. But to get there you first have to mount the raid-array using mdadm-tools (if not installed, now is a great time)

sudo mdadm --assemble --run /dev/md0 /dev/sdb2
mdadm: /dev/md0 has been started with 1 drive (out of 2).

Now we have access to the raid, but the filesystem is within a lvm, so we need to find out the name of the part we want to mount

sudo pvs
  PV         VG          Fmt  Attr PSize PFree
  /dev/md0   18796e6b_vg lvm2 a-   1.80t    0

Here we see that our lvm volume group is 18796e6b_vg, with that name we can gather the information to  mount the partition

sudo lvdisplay /dev/18796e6b_vg
  --- Logical volume ---
  LV Name                /dev/18796e6b_vg/lv592c2f3
  VG Name                18796e6b_vg
  LV UUID                eHpAEe-dmRV-pFa9-XCV5-LjEt-HXl9-8rDaKt
  LV Write Access        read/write
  LV Status              available
  # open                 0
  LV Size                1.80 TiB
  Current LE             471809
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           252:0

LV Name is the name of the device we need to mount /dev/18796e6b_vg/1v592c2f3. If the LV status says Not available you will have to use

vgchange -ay

to activate all known volume groups or else you’ll get something like

mount: special device /dev/18796e6b_vg/lv592c2f3 does not exist

when you try to mount it.

Finally all is setup, we just have to mount the LV Name, in our case /dev/18796e6b_vg/1v592c2f3

sudo mount /dev/18796e6b_vg/1v592c2f3 /mnt

and now you can access the data using /mnt

JQuery UI Autocomplete Suchwort makieren

Mir stellte sich Die frage wieso der jQuery UI Autocomplete kein Suchwort makiert und bin auf der UI Seite auf eine Lösung gestoßen

new RegExp("(?![^&;]+;)(?!<[^<>]*)(" +$.ui.autocomplete.escapeRegex(request.term) + ")(?![^<>]*>)(?![^&;]+;)", "gi"), "<strong>$1</strong>" ),

Super sache gleich mal ausrobieren. Leider nur mit mäßigem erfolg.

In meinem Autocomplete stand nur kein fett geschriebenes Wort sondern der HTML tag an sich.

Nach einer kleinen Rescherche bin ich auf eine Webseite gestoßen die sich mit dem selben Problem befasst hatte und dort schreibt das jQueryUi die Renderausgabe für den Autocomplete auf text() umgestellt hatte der bakanntlich die HTML tags escapet.

Hier die Lösung auf das Problem. wir geben unserem jQuery UI autocomplete einfach eine eigene Render function

$[ "ui" ][ "autocomplete" ].prototype["_renderItem"] = function( ul, item) {
return $( "<li></li>" ) 
  .data( "item.autocomplete", item )
  .append( $( "<a></a>" ).html( item.label ) )
  .appendTo( ul );
};

tada mein Suchwurt wird nun Fett geschrieben

Hier mein Kompletter Autocomplete Aufruf:

<script type="text/javascript">
	/* this allows us to pass in HTML tags to autocomplete. Without this they get escaped */
	$[ "ui" ][ "autocomplete" ].prototype["_renderItem"] = function( ul, item) {
	return $( "<li></li>" ) 
  		.data( "item.autocomplete", item )
  		.append( $( "<a></a>" ).html( item.label ) )
  		.appendTo( ul );
	};
	$(document).ready(function() {
		$( "#autocomplete" ).autocomplete({
			source: function( request, response ) {
				$.ajax({
					url: "/orte.html",
					dataType: "json",
					data: {
						term: request.term
					},
					success: function( data ) {
						response( $.map( data, function( item ) {
							var regExTerm = "(?![^&;]+;)(?!<[^<>]*)(" + $.ui.autocomplete.escapeRegex(request.term) + ")(?![^<>]*>)(?![^&;]+;)"
							return {
								label: 
									item.postalcode.replace(new RegExp(regExTerm, "gi"), termTemplate) + ", " + item.place.replace(new RegExp(regExTerm, "gi"), termTemplate),
								value: 
									item.postalcode + ", " + item.place,
							}
						}));
					}
				});
			},
			minLength: 2,
		});
	});
</script>

WordPress – 404 “Page not found” on form submit

I was fiddling on a wordpress-plugin today when I encountered a strange error, the moment I submitted a form WP gave me a sweet little 404 error.

To keep things short, this was not directly related to the form submit or the POST-method used in it. After digging around in WP it came to light that there is a bunch of reserved variable names for queries. So whenever you submit a form or call a WP-url which returns a 404 and you are pretty damn sure that the url is correct check the wp-includes/class-wp.php file for the arrays $public_query_vars and $private_query_vars, these variables are your enemy in that case (see below).

When you know what to search for there is also a page concerning this in the WordPress Codex.

 

	 
    /**
     * Public query variables.
	 *
	 * Long list of public query variables.
	 *
	 * @since 2.0.0
	 * @access public
	 * @var array
	 */
	var $public_query_vars = array('m', 'p', 'posts', 'w', 'cat', 'withcomments', 'withoutcomments', 's', 'search', 'exact', 'sentence', 'calendar', 'page', 'paged', 'more', 'tb', 'pb', 'author', 'order', 'orderby', 'year', 'monthnum', 'day', 'hour', 'minute', 'second', 'name', 'category_name', 'tag', 'feed', 'author_name', 'static', 'pagename', 'page_id', 'error', 'comments_popup', 'attachment', 'attachment_id', 'subpost', 'subpost_id', 'preview', 'robots', 'taxonomy', 'term', 'cpage', 'post_type');

	/**
	 * Private query variables.
	 *
	 * Long list of private query variables.
	 *
	 * @since 2.0.0
	 * @var array
	 */
	var $private_query_vars = array('offset', 'posts_per_page', 'posts_per_archive_page', 'showposts', 'nopaging', 'post_type', 'post_status', 'category__in', 'category__not_in', 'category__and', 'tag__in', 'tag__not_in', 'tag__and', 'tag_slug__in', 'tag_slug__and', 'tag_id', 'post_mime_type', 'perm', 'comments_per_page', 'post__in', 'post__not_in');

Rerender proxy clips in Kdenlive

How to render proxy clips in Kdenlive again (e.g. after you’ve change the quality settings for the proxies):

Double click the clip in the project tree and click the button “Delete proxy”. After that the proxy clip should be created again.

mysql_ Muninplugin is missing Cache::Cache

The default setup for Munin in Debian seems to miss some packages for the mysql_ plugin.

/usr/share/munin/plugins/mysql_ suggest

will give you

Missing dependency Cache::Cache at /usr/share/munin/plugins/mysql_ line 716.

The solution was easier than excpected:

aptitude install libcache-cache-perl

and done.

Beware the difference between split & tokenize

There is a little difference between tokenize and split in Groovy:

def csv = "1,,3,4,5"

println csv.split(",")
println csv.tokenize(",")

results in

[1, , 3, 4, 5]
[1, 3, 4, 5]

Note that tokenize ignores the empty element.

Edit: I just found this blog-post covering the same topic

Resource on writing Magento plugins

I’ve poked around the web for while to find some good resource about how to add my own controller to Magento and this turned out very usful:

http://www.about-magento.com/magento-developper-guide-howto-tutorial-5

Thanks to Pierre! =)