Mock Data Generation

Sometimes you need mockdata to upload to a DB or to test on an altenative datastore. For that Mockaroo.com works perfectly as you can define the expected field values in ranges and so generate a matching DataSet very fast. I used it to feed my elasticsearch instance for testqueries against a db schema layout that needed to be designed.  The datavalues can be choosen in a wide variety of know formats and standard values. (e.g. date, currency, country) Output formats are json, sql, csv and many more.

Need Flat Icons ?

If you need flat design icons or graphics for your app or site, check out :

http://flaticons.net

All is free for every use. You can customize interactively color, padding, framing and background. Huge library. Great ..

Manually grep Android SDK Manager Jars

The Android SDK Manager seems in various versions buggy. On Windows I recognized parts of the extra packages are not displayed in the download list. On Linux I recognized not the latest packages seems to be available. Although all displayed is based on the

http://dl-ssl.google.com/android/repository/repository.xml

http://dl-ssl.google.com/android/repository/addon.xml

repo files the SDKManager doesn’t update correctly.  Advices on the net always hint to install the latest version. But there exists a manually method too.

Easily lookup the target filename by directing your browser either for SDK packages to repository.xml or for addon/extra packages to addon.xml.

<sdk:url>support_r09.zip</sdk:url>

Then construct your target file url by simply merging both

http://dl-ssl.google.com/android/repository/support_r09.zip

Drag’n Drop in Android 4 ICS+

Create a custom ListView and add a Listener via a following method.
Add a ClipData Object to identify the selected row.

/**
* Setup what to do when we drag list items
*/
public void setupDragDrop() {
this.setOnItemLongClickListener(new OnItemLongClickListener() {
public boolean onItemLongClick(AdapterView arg0, View v,
int position, long arg3) {
ClipData data = ClipData.newPlainText("procedure", position
+ "");
v.startDrag(data, new DragShadowBuilder(v), null, 0);
return true;
}
});
CustomDragListener mDragListener = new CustomDragListener();
this.setOnDragListener(mDragListener);

Create the CustomDragListener to decorate the behaviour of your Drag’n Drop.
For simplicity we will just handle ACTION_DROP event.
Use ListView’s pointToPosition() function to determine target position id.

protected class CustomDragListener implements OnDragListener {
public boolean onDrag(View v, DragEvent event) {
final int action = event.getAction();
switch (action) {
case DragEvent.ACTION_DRAG_ENTERED:
return false;
case DragEvent.ACTION_DRAG_EXITED:
return true;
case DragEvent.ACTION_DRAG_STARTED:
return true;
case DragEvent.ACTION_DRAG_LOCATION:
return false;
case DragEvent.ACTION_DROP:
v.setBackgroundColor(Color.TRANSPARENT);
int newPosition = pointToPosition((int) (event.getX()),
(int) event.getY());
if (newPosition != ListView.INVALID_POSITION)
return processDrop(event, newPosition);
else
return false;
default:
return true;
}
}

Unwrap old position from ClipData and call helper function to update UI.

private boolean processDrop(DragEvent event, int newPosition) {
ClipData data = event.getClipData();
if (data != null) {
if (data.getItemCount() > 0) {
Item item = data.getItemAt(0);
int value = Integer.parseInt(item.getText()+"");
updateViewsAfterDropComplete(value, newPosition);
return true;
}
}
return false;
}

Update UI and Model if binding should be processed further.

private void updateViewsAfterDropComplete(int oldIndex, int index) {
ArrayList<MyListEntry> actual = myListStructure.getEntries();
MyListEntry entry = actual.get(oldIndex);
actual.remove(oldIndex);
actual.removeAll(Collections.singleton(null));
actual.add(index, entry);
myListStructure.setEntries(actual);
db.updateMyListStructure(myListStructure);
repaintUi();
}

Get dm-raid booting with lvm2 and grub (debian)

The use of the so called fakeraid or softraid is often not adviced. I don’t want to advice it also as I didn’t have to rescue my System yet. But there are possibilities. But from the performance view it doesn’t behaves bad on my system with around 150MB/s in raid1 < in contrast to> my expensive 3ware 9550SXU hwraid-system with 70MB/s.

Some specialaties are to notice during install (with debian squeeze 6.04 installer):

Since the physical volume name is provided randomly by the dmraid driver (according to your chipset), your partitions are mapped with somthing like that:

nvidia_cffbdeda <- the physical device

nvidia_cffbdeda1 <- partition 1

nvidia_cffbdeda2 <-partiton 2

 

You have to install grub afterwards again by rescue cd or chrooted into installation as during install it will fail and the system won’t be bootable the first time. Install it into MBR which means the nvidia_cffbdeda <- the physical device with the following modification:

apt-get purge grub2 grub-pc grub-common
rm -R /boot/grub
apt-get install grub-pc
update-grub
grub-install /dev/mapper/nvidia_cffbdeda
grub-install –recheck /dev/mapper/nvidia_cffbdeda

check this link for a complete grub reinstall guide: here

The installer usually creates an own partition for /boot which will be linked in the root filesystem (nvidia_cffbdeda1). This is partition1. As you installed with lvm the whole volume group resides in partition2. There you have your different volumes for /root /data /swap. All are in partition2.

 

fstab problem (partition naming problem):

A problem I regognized was that the installer declares the dmraid-partitions internally in fstab as

nvidia_cffbdedap1 insteadof nvidia_cffbdeda1

and

nvidia_cffbdedap2 insteadof nvidia_cffbdeda2

It is a new naming rule which seems not having found it’s way to all components dmraid and lvm2 yet.

 

So even if grub was twice ran correctly it can’t find the /boot partition nvidia_cffbdeda1 as fstab refers to nvidia_cffbdedap1. Changing there to the correct value resulted in a correct boot.

 

Finally we can say:

1) the naming of your virtual dm-raid partitions can be found via

ls /dev/mapper/

change fstab values according to this naming.

2) grub is aware of dmraid and lvm2 partitions and can initialize them before boot which means that you don’t have to create an own /boot partition (which I have read quite often). You can install everything in your root filesystem and let grub boot from there although the installer does it differently.

Some links:

http://pve.proxmox.com/wiki/Install_Proxmox_VE_on_Debian_Squeeze

http://ubuntuforums.org/archive/index.php/t-1338445.html

http://forum.proxmox.com/archive/index.php/t-7569.html

 

 

dmraid, lvm2 commands to know

A brief commad list to handle your partition/volumes :

dmraid:

dmraid -s [show active dmraid set]

dmraid -l [list available driver]

dmraid -ay [activate dmraid set]

lvm:

lvdisplay –v [Show current logical volumes]

umount /dev/VolumeGroupName/data [unmount logical volume 'data'

lvremove /dev/VolumeGroupNam/data [ensure you backup anything there first to another location or server]

pvdisplay –v [show current physical volumes]

pvcreate /dev/sdxxx [create new physical volume for use. This is your new HDD or array. If you are unsure the exact device, look under /dev dir. You can also use fdisk -l to help]

pvdisplay –v [Your new physical volume should now be visable]

vgdisplay –v [display size and config of volume group]

vgextend /dev/VolumeGroupName /dev/sdxxx [This will extend the volume group by the new physical volume you have added above]

lvcreate –n /dev/VolumeGroupName/data –L sizeG [This will create your new /data store in the volume group Note: The G after size is a value in Gigabytes]

lvdisplay –v [You should now see your new data store with the larger size, this can be >2TB]

mkfs –T ext3 /dev/VolumeGroupName/data [This will format your new store ready for use]

How to get Eclipse / Workspace / IProject Paths programmatically

How to get the Paths in an Eclipse Extension:

System.out.println( "EclipseInstallPath=" + Platform.getInstallLocation().getURL().getFile() );
System.out.println( "WorkspacePath=" + Platform.getInstanceLocation().getURL().getFile() );
System.out.println( "WorkspaceCopyPath=" +iProject.getLocation().makeAbsolute().toFile().getParent() );

How to get the Projects :

IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects();

Needs to reference the

org.eclipse.core.resources

Plugin setable under RequiredPlug-Ins in the Dependencies Tab of the Manifest.mf (in a default PDE-Project)