Showing posts with label technics. Show all posts
Showing posts with label technics. Show all posts
I have compiled some useful features of three desktop environments into one desktop environment. The global menu which is effectively applied in the MacOS, the idea of left dock of Ubuntu, the lightweight-ness of XFCE, and the productive-ness of Xmonad, one of the tiling window managers. I made a script that automatically turns Ubuntu based Xfce desktop to my configuration. I recommend trying this on a Linux Lite installation. Alternatively, you could try installing it on an Ubuntu box with Xfce installed, or on Xubuntu. Feedbacks are all welcome about other distributions. Xmonad is configured using xmonad.hs in ~/.xmonad. According to the configuration, the mod key is set as Win/Cmd key. The keyboard shortcuts are as follows:

ShortcutTask
Shift + Mod + c Close the active window
Shift + Mod + s Take xfce4-screenshot
Shift + Mod + x Reverse tiling windows according to x-axis
Shift + Mod + y Reverse tiling windows according to y-axis
Shift + Mod + h Increase the width of left pane
Shift + Mod + l Increase the width of right pane
Mod + Up Increase the height of windows in the right pane
Mod + Down Decrease the width of windows in the right pane
Mod + Space Switch to another tiling setup
Mod + Tab Switch to next window in the workspace
Mod + z Switch to the previous workspace
Mod + (1|2|3|4|5|6|7|8|9) Switch to the workspace indicated by the number
Shift + Mod + (1|2|3|4|5|6|7|8|9) Move the active window to the workspace indicated by the number


The ordering of the tiling setups are as follows:
  1. Master window on left, others on right
  2. Master window on top, others at bottom
  3. Only master window in full screen with left and top panels
  4. Only master window in full screen (useful for watching full screen video)
If there are multiple windows in a workspace, the active window will have a red border. The script will install the packages below using apt:
xmonad, xfce4-dockbarx-plugin, gnome-terminal, zeitgeist, python-xdg, vala-panel-appmenu, appmenu-gtk3-module, appmenu-gtk2-module, appmenu-qt, gnome-terminal, xmonad, shutter, xfce4-appmenu-plugin, xfce4-systemload-plugin, arc-theme

Please note that, the script will install google-chrome amd64 binary. If you have other hardware, you should modify the related line. The script will install Arc Dark theme and switch to it.

After running the script, you will have a desktop environment that looks like the following screenshots:

You can preview media easily utilizing the tiling window manager:


You can prepare your own IDE like environment. For example, the picture shows preview of a pdf paper at the right side, and tex file editor at the left. At the bottom of the left side, a command line is present to compile the tex file into pdf. The pdf viewer at the right side immediately previews if a new compilation occurs.


The following pictures show Chrome in full screen. The first picture demonstrates the top global menu. The second picture demonstrates the left dock.



I am doing experiments with tweets. For each tweet or each set of tweets, several APIs need to be called trough http protocol. This takes time. I often repeat the same experiment, which means issuing the same http request over and over again. Each request takes at least half a second. Considering a million tweets, one experiment takes half million seconds which makes over 5 days. And, this is the case for only one request per tweet.

In order to overcome this, I cache requests and responses. I made a library for php. Below I will be giving the codes. The library issues curl. But before issuing curl, if cache option is set, it first check if there is a cached content for this request. If there is, it simply returns the cache content. Otherwise, it requests the content over the network, and caches it for further requests.

Caching is done by saving the response to a file named by the md5 of the request url. Since the number of files in the cache directory is too high, I applied a two level strong mechanism which gets first two chracters of the md5 hash and saves the file in the directory named with those two chracters. This reduces the number of files in one directory, enabling a two level look-up in the file system.

Below is the simple code. It, for sure, needs further improvement but, for now, it works for me.


function curl_get($url, $cache=false)
{
$md5filename=getFileName("urlcache",$url);
if($cache==true)
        {
        if(file_exists($md5filename))
                return file_get_contents($md5filename);
        }
$defaults = array();
@$defaults[CURLOPT_URL] = $url;
@$defaults[CURLOPT_HEADER] = 0;
@$defaults[CURLOPT_RETURNTRANSFER] = TRUE;
@$defaults[CURLOPT_TIMEOUT] = 0;
$ch = curl_init();
curl_setopt_array($ch, $defaults);
if( ! $result = curl_exec($ch))
        {
        $retry = 0;
        while($retry < 10){
                sleep(10);
            $result = curl_exec($ch);
        if($result)break;
        if(!$result)
                trigger_error(curl_error($ch));
        }
curl_close($ch);
if($cache==true)
        {
        $f=fopen($md5filename,"w");
        fwrite($f,$result);
        fclose($f);
        }
return $result;
}

function getFileName($infix,$data)

{

$md=md5($data);
$st=substr($md,0,2);
$md=$st."/".$md;
@mkdir(__DIR__."/../caches/$infix/$st");
return __DIR__."/../caches/$infix/".$md;
}


I have just compiled xdAuto 1.1.6e for the head unit NR5002 in my car. I was having an error in the cold boot that stops the radio. No problem in manually opening the radio app.

If the car is shut down while the radio is running, in the boot, it starts by the radio automatically. I often experience "Radio stopped unexpectedly" error. I have opened a bug report in here. One of the guys out there came up with a simple fix.

Just by editing the file Radio/src/com/example/radio/RadioActivity.java

by changin the following lines in protected void onPause() {

stopScan();
unbindService(this);
to
if (radioService != null) {
stopScan();
unbindService(this);
}

and compiling the android system solved my problem. 

I compiled the whole android system after the change. The compilation instructions are as follows for the ones who are interested (I am running ubuntu12.04) :

sudo apt-get install gcc
sudo apt-get install bison
sudo apt-get install g++-multilib
sudo apt-get install git
sudo apt-get install gperf
sudo apt-get install libxml2-utils
sudo apt-get install make
sudo apt-get install python-networkx
sudo apt-get install zlib1g-dev:i386
sudo apt-get install zip
sudo apt-get install flex
sudo apt-get install libncurses5-dev
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java6-installer

mkdir ~/Nu3001
mkdir ~/Nu3001/bin
PATH=~/Nu3001/bin:$PATH
cd ~/Nu3001
curlhttps://storage.googleapis.com/git-repo-downloads/repo > /Nu3001/bin/repo
chmod a+x ~/Nu3001/bin/repo

git config --global user.email "nu3001@nu3001.com"
git config --global user.name "nu3001"
repo init -u https://github.com/Nu3001/platform_manifest.git -b master
repo sync

cd ~/Nu3001/kernel
export ARCH=arm
exportCROSS_COMPILE=../prebuilts/gcc/linux-x86/arm/arm-eabi-4.6/bin/arm-eabi-
export UTS_RELEASE="3.0.36+"
make amplified_defconfig
make kernel.img
make modules
sudo make modules_install

cd ~/Nu3001
source build/envsetup.sh
lunch rk3188-eng
make otapackage

After these steps, a zip file is created in ~/Nu3001/out/target/product/rk3188. That zip file can be used to update the whole android system usin TWRP. In my case, I just needed BonovoRadio.apk. So I unzipped the zip file and took that file from there. I just replaced the apk in /system/app folder in my head unit and rebooted. The problem just went awayy!!

Here is a pic of my head unit: