Search This Blog

Monday, April 29, 2013

Archlinux 24/7 uptime installation on a pendrive - limit flash IO (reads/writes)

Installing a box that runs 24/7 on a pendrive seems not like a best idea at first - continuous reads and writes would destroy the flash memory withing months of usage. There are some ways to minimize these, however. Two of them that come to mind at first are - let the swap file reside on a HDD instead of flash card. What about logs? - let us keep them in memory and discard when the box is being shut down.

Linux mounts partitions at boot from a file: /etc/fstab

Let /dev/sdb1 be our HDD partition and /dev/sda our flash card.
At first we need to mount HDD partition to any directory on the root of the file-system /

/dev/sdb1              /home/user/movies     ext4    defaults        0       0

Let's move the swap file to HDD instead of a flash card:

/home/user/movies/swapfile   none    swap    defaults        0       0

And create a temporary partition (discarded at shutdown) with the logs.


tmpfs   /var/log        tmpfs   defaults,noatime,mode=755       0       0


So the whole /etc/fstab file will look like this:

#
# /etc/fstab: static file system information
#
# <file system>        <dir>         <type>    <options>          <dump> <pass>
devpts                 /dev/pts      devpts    defaults            0      0
shm                    /dev/shm      tmpfs     nodev,nosuid        0      0
/dev/sdb1              /home/user/movies     ext4    defaults        0       0
/home/user/movies/swapfile   none    swap    defaults        0       0
tmpfs   /var/log        tmpfs   defaults,noatime,mode=755       0       0


Monday, March 11, 2013

Huawei MediaPad 10 FHD (Chinese edition) C233B003/C233B001 Root and Google Apps (Google services/GApps)

The article describes rooting and gapps installation process on Huawei MediaPad 10 FHD imported from China.
The device in question: huawei site and gsm arena.

Some advice before buying/rooting:

  • DO NOT buy the Chinese version if you have a choice. Due to some licencing issues the C233B003  has NEITHER google services NOR google play/GMail/YouTube apps installed by default (GApps're actually disabled - but cannot be turned on without rooting&using a Chinese script)
  • Due to a blocked bootloader you cannot flash a European version of the ROM to a Chinese tablet - fortunately the Chinese ROM is Android 4.1.2 and has English language (but no gapps)
  • the Chinese ROM has a lot of rubbish installed - Chinese internet browsers, their own store etc.
Before flashing any ROMs you need to remember that there are 3 types of these devices:
  • S10-101w - the Wifi only version
  • S10-101L - LTE edition
  • S10-101u - 3g edition
Chinese ROM can downloaded here (huawei website).
ROM I used for S10-101w is available for direct download here.

Rooting & GApps for S10-101w C233B003/C233B001 can be download here.
(MediaPad 10 FHD固件(S10-101w,Android4.1,C233B003,中国区WIFI 4.1版本))


Rooting process & installing Google apps:
Root

1. [Optional if already installed on a tablet] Download a Chinese ROM - Android 4.1, C233B003 (for S10-101w version)
2. Power on the device, connect the usb cable (in HiSuite mode) - download and install HiSuite from a link (or from a website).
2. Disconnect usb cable, connect it again and select MTP mode - there should a device "Huawei MediaPad" in "My computer"
3. Run "Root.bat" from the package in folder /Huawei_MediaPad_10_FHD_ChineseVersion_C233B003_C233B001_Root_And_Google_Apps/1_BootloaderUpdate/Huawei_S10-101w_V100R002C233B003_Root_Repair_Downgrade . The process takes about 12 minutes. Includes several restarts and displays several errors - in the end you should have a rooted pad.
4. Check that you have a super su app on the tablet and that you have root privileged.

Google apps:
5. The tablet is missing Google services which are required to run e.g. Google Play Store. Transfer "ActiGSM.apk" to your freshly rooted tablet and install it. Then run the script (by just simply running the application for an application drawer) which will enable google services and all google apps on your tablet.




Friday, February 8, 2013

Git - running garbage collection on your repository

There is a neat feature of git called "garbage collection" that I recently got familiar with. My half-a-year repository which had 1.6 GB (the .git folder itself having had 424 MB) was shrunk to 1.5 GB (with the .git folder having 292 MB).


C:\Repo\.git>git gc
Counting objects: 55965, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (15987/15987), done.
Writing objects: 100% (55965/55965), done.
Total 55965 (delta 42100), reused 52422 (delta 38932)

There is also an "aggressive" garbage collection option which you can use:


--aggressive

Usually git-gc runs very quickly while providing good disk space utilization and performance. This option will cause git-gc to more aggressively optimize the repository at the expense of taking much more time. The effects of this optimization are persistent, so this option only needs to be used occasionally; every few hundred changesets or so.

For more info have a look here.

Silverlight DevExpress DXperience Grid Printing Layouts

This example shows how to use simple templates in DevExpress printing mechanism. The most important thing you can't miss is that it is absolutely essential to use DevExpress template controls in DataTemplate - plain Silverlight controls are simply removed when the template is processed. In this example this is <dxe:TextEdit /> used instead of Silverlight's <TextBlock>.

<UserControl
   [....]
  xmlns:dxe="http://schemas.devexpress.com/winfx/2008/xaml/editors">
  <UserControl.Resources>
    <DataTemplate x:Key="headerTemplate">
      <dxe:TextEdit  Text="{Binding Path=Content, Mode=OneWay}" />
    </DataTemplate>
  </UserControl.Resources>
  [....]
</UserControl>

var preview = new DocumentPreviewWindow();

var link = CreateExportServiceLink(gridControl, preview);
PrepareHeader(link);

private PrintableControlLink CreateExportServiceLink(

IPrintableControl gridControl, 
DocumentPreviewWindow documentPreviewWindow)
{ var link = new PrintableControlLink(gridControl)
{
ExportServiceUri = "http://127.0.0.1:8080/IExportService",
Landscape = true
};
var model = new LinkPreviewModel(link);
documentPreviewWindow.Model = model;

return link;}

private void PrepareHeader(PrintableControlLink link)
{

link.ReportHeaderTemplate = (DataTemplate)Resources["headerTemplate"];
link.ReportHeaderData = "Text to be displayed";
}


Java generic methods; Java generic classes; Java static generic method

Java has a different syntax for generic methods, generic classes and static generic methods.

  • Java generic classes
public class ComboBoxDefinition<T extends Identifiable> extends AbstractFieldDefinition implements xxxx
{
    protected ComboBoxDefinition(BeanContainer<T> beanContainer)
    {
    }
}
  • Java generic methods
public class ComboBoxDefinition
{
    public void draw(List<? extends Control> controls) {
    }
}
  • Java static generic methods
public class SomeClass
{
     public static <T extends Identifiable> void create(BeanContainer<T> beanContainer) {
        
    }
}

Silverlight call simple get (REST/HTTP) and receive an image

This is the simplest method to receive an image from http server - we receive a stream with the message.


var wc = new System.Net.WebClient();
var applicationHostSource = Application.Current.Host.Source;
var request = "http://" + applicationHostSource.Host + ":" + applicationHostSource.Port +"/" + "Image.png";
wc.OpenReadCompleted += (sender, downloadStreamCompletedEventArgs) =>
{
var stream = downloadStreamCompletedEventArgs.Result;
var image = new BitmapImage();
image.SetSource(stream);
StoredImage = image;
};

wc.OpenReadAsync(new Uri(request));

Monday, January 7, 2013

Aero2 Poland APN settings

Aero 2 is an operator that serves free internet access in Poland. To set APN settings in Aero2 on an Android device just enter these:


Nazwa: darmowy
APN: darmowy
Proxy: <nie ustawiono>
Port: <nie ustawiono>
Nazwa Użytkownika: <nie ustawiono>
Hasło: <nie ustawiono>
Serwer: <nie ustawiono>
MMSC: <nie ustawiono>
Proxy dla wiadomości MMS: <nie ustawiono>
Port MMS: <nie ustawiono>
Protokół MMS: <nie ustawiono>
MCC: 260
MNC: 17
Typ uwierzetylnienia: <nie ustawiono>
Typ APN: <nie ustawiono>



Name: darmowy
APN: darmowy
Proxy: <nie ustawiono>
Port: <nie ustawiono>
Username: <nie ustawiono>
Password: <nie ustawiono>
Server: <nie ustawiono>
MMSC: <nie ustawiono>
MMS message proxy: <nie ustawiono>
MMS port: <nie ustawiono>
MMS Protocol: <nie ustawiono>
MCC: 260
MNC: 17
Authorization type: <nie ustawiono>
APN type: <nie ustawiono>