10 September 2014

Layin a simple Serlvet-base Layout utility

https://github.com/MuhammadHewedy/Layin/

02 September 2014

Objective-c delegates

It is a long time I since I stopped working on iPhone and objc.

But some collage is working and we was discussing about objc delegates and what is it and how it is related to categories.

Following is an example illustrate how things going from Categories to Delegates.


// NSObject+TurnLights.h
// a Category on NSObject to allow any subclass to turn on/off lights
@interface NSObject (TurnLights)

-(void) turnLightsOn;
-(void) turnLightsOff;

@end

//Lights.m
// this is the lights class that delegate its work to some object (of type id) to do the on/off instead of itself
@implementation Lights

@synthesize id delegate;

-(void) doLightings{
      [delegate turnLightsOn];
      [delegate turnLightsOff];
}
@end


//MyContorller.m
// is my controller class that decided to be a delegate for the Lights class

#import "NSObject+TurnLights.h"

@implementation MyController

-(void) btnClicked:(id) sender{
      Lights* lights = ...
      [lights setDelegate: self];
}

-(void) turnLightsOn{
      NSLog("turnLightsOn");
}

-(void) turnLightsOff{
      NSLog("turnLightsOff");
}
@end

30 May 2014

continually monitor CPU usage for a command

cmd=[m]oviecrawler;while :; do echo -ne "CPU: `ps aux | grep $cmd | awk '{print $3}'`\\r" ;  sleep 1; done

11 May 2014

Banshee souldcloud integeration

I wanted to play sounds from soundcloud on banshee...

I found source code on githug, I've forked to fit my needs

Project at github
https://github.com/MuhammadHewedy/banshee-soundcloud-extension


10 May 2014

refactor (find and replace in files)

If you want to refactor (find and replace in files) , you could use the following script (on your own)

https://gist.github.com/MuhammadHewedy/dab0116aa288f67d05ba

07 May 2014

Obtain the best look ever for Intellj on Linux

(1) install freetype
$ sudo apt-get install libfreetype6

(2) install infinality patch (https://launchpad.net/~no1wantdthisname/+archive/ppa)
$ sudo add-apt-repository ppa:no1wantdthisname/ppa
$ sudo apt-get update
$ sudo apt-get install fontconfig-infinality

I had to do the following afterwards:
$ sudo rm /etc/fonts/conf.avail/52-infinality.conf
$ sudo ln -s /etc/fonts/infinality/infinality.conf /etc/fonts/conf.avail/52-infinality.conf

To use Windows 7 like font rendering do the following:
$ sudo /etc/fonts/infinality/infctl.sh setstyle osx
Set USE_STYLE to "osx" in /etc/profile.d/infinality-settings.sh

(3) install font fixed OpenJDK (https://launchpad.net/~no1wantdthisname/+archive/openjdk-fontfix)
$ sudo add-apt-repository ppa:no1wantdthisname/openjdk-fontfix
$ sudo apt-get update
$ sudo apt-get install openjdk-7-jdk

To use this JDK only for IntelliJ, prepend this line to bin/idea.sh:
IDEA_JDK="/usr/lib/jvm/java-1.7.0-openjdk-amd64"

(4) JVM options
Add the following options to the .vmoptions file of IntelliJ
-Dawt.useSystemAAFontSettings=lcd
-Dswing.aatext=true

(5)
Perform a reboot

(6)
See the result with default Darcula theme in attachment.

Hope this helps someone!


Source:
http://youtrack.jetbrains.com/issue/IDEA-57233#comment=27-472038

BTW, I've tried this on Idea 13.1 on Ubuntu 14.04 and it works like a charm ... here's an screenshot ..



Display apps on unity launcher

If you have app and want to display it when search in unity launcher... you need to add an entry for it in `/usr/share/applications`

example:

/usr/share/applications$ cat idea.desktop
[Desktop Entry]
Version=13.1
Name=Intellj Idea
Exec=/home/mhewedy/disk/programs/idea-IC-135.480/bin/idea.sh
Icon=/home/mhewedy/disk/programs/idea-IC-135.480/bin/idea.png
Terminal=false
Type=Application
Actions=
Categories=Programming
Actions=Profile;Tray;
Keywords=idea;java;intellj;ide # keywords to search with to find the app, very important



That's all!