Recently I bought a ultra-wide monitor which a really weird but useful 21:9 aspect ratio.The only way mac would support this if i get a mini displayport to displayport adapter.

Since some orders take weeks for souq to fullfil.I decided to the use the single DVI cable from my older monitor on the new one.Once I plugged it in I faced the same issue the mac would only render only upto Full HD or 1920 X 1080.After a quick googling I found that SwitchResX can solve this issue.

But for some reason every time I create a custom resolution of 2560 X 1080,SwitchResX would not save it and if it did it would say not installed.I tried this a couple of times.I even deleted all the SwitchResX files and even uninstall SwitchResX from the menu bar.

Even setting the resolution was really  difficult, after rebooting a couple of times I finally got it working with the following settings.

Screen Shot 2015-04-09 at 10.27.03 AM

 

To get SwitchResX to save the settings.Follow the instructions in these instructions:

  • Create a new user on the mac
  • Install the SwitchResX application,this will start the 10 days trial.
  • Create the resolution profile and save it.
  • It should prompt you to reboot the mac.Please do so.

And Voila the resolution is should now present on your original user’s SwitchResX.Now you can select it in the current resolution tab.



Apache 2 is a well know server for linux.Setting up an SSL certificate on it is very simple  and straightforward.

Firstly we need an SSL certificate,We can get it from numerous online SSL providers or we could generate one ourself.

To generate a 2048 bit key.

sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/apache2/ssl/apache.key -out /etc/apache2/ssl/apache.crt

This will create your public ssl certificate and a private key.

Next we have to enable ssl module for apache2

sudo a2enmod ssl

Once have this enabled,Lets add the certificate to all of the websites running on the server.On apache2 you can find the websites on /etc/apache2/sites-available/.Lets change the default-ssl.conf file on the /etc/apache2/sites-available/default-ssl.conf.

Just change a couple to lines in the file.

SSLEngine on
SSLCertificateFile /etc/apache2/ssl/apache.crt
SSLCertificateKeyFile /etc/apache2/ssl/apache.key

These configurations tell apache which certificate to use and which key goes along with it.All we have to do now is enable the configuration

sudo a2ensite default-ssl.conf

And then to restart the apache2 server

sudo service apache2 restart

 



In Ruby 2.0 we were first introduced to keyword arguments.Keyword Arguments are really useful and they clean up the redundant code.

Pre 2.0

def get _stuff(options={})
    first = options.fetch(:first)
    last = options.fetch(:last)
end

Now

def get_stuff(last:'last',first:'first')
end

So now we dont need to fetch arguments out of a hash we can just pass it along to the function and it becomes available as arguments.

But with comes at a cost.If you want to specify optional arguments this breaks really easily.Lets take this example.We have a method with two keyword arguments and we want to override the first argument

def get_stuff(first:"first",last:'last')
end

get_stuff("really_first")
#ArgumentError: wrong number of arguments (1 for 0)

We get this error because the method expects there to be a key value in the arguments of the method.Moreover ruby spits out its regular ArgumentError wrong number of arguments(1 for 0).

Currently there is not go way to avoid this sort of issue.Nevertheless keyword arguments offer more flexibility and structure to the code.We can also mix together a hash and keyword argument.

def ff(test:1,more:10)
   "#{test} #{more}"
end

hash = { test: 2, more: 1000}

ff hash # => "2 1000"

This code works well until the hash keys are the same as the keyword argument

hash = { test: 2, more: 1000, extra: 1}

ff hash # => ArgumentError: unknown keyword: extra

Again there is no good way around this apart from cleaning up the arguments before you pass it to the function



A year ago google released android studio.An IDE based on intellij.They also introduced a task runner to build your applications, run test and manage dependencies.

Gradle is the task runner and it supports a Java,Android and C/C++ projects.That what they claim on their website.But for this post I will be dealing with android.

The android gradle project has buildTypes which are equivalent to environments in the backend development world.Android has 2 by default one is debug the other is release.You can specify more buildtypes based on your application.

You can easily create another buildtype

signingConfigs {
        prerelease {
            storeFile file("prerelease.keystore")
            storePassword "<your password>"
            keyAlias "<key.alias>"
            keyPassword "<your password>"
        }
    } 
buildTypes {
        prerelease {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            signingConfig signingConfigs.prerelease
        }
    }

You need to add the signingConfig this way it will build and sign the keys before installing.

By default the Install<Buildtype> doesn’t show and the only way to show it is to have signingConfig specified in the buildtype.

Here are the other options available to each buildtype

If a property is not set through the DSL, some default value will be used. Here’s a table of how this is processed.

 

 Property Name  Default value in DSL object  Default value
 versionCode  -1  value from manifest if present
 versionName  null  value from manifest if present
 minSdkVersion  -1  value from manifest if present
 targetSdkVersion  -1  value from manifest if present
 applicationId  null  value from manifest if present
 testApplicationId  null  applicationId + “.test”
 testInstrumentationRunner  null  android.test.InstrumentationTestRunner
 signingConfig  null  null
 proguardFile  N/A (set only)  N/A (set only)
 proguardFiles  N/A (set only)  N/A (set only)

Source: Google

By default gradle looks for the keystore file in the app/ directory.

You can also run multiple gradle jobs in parallel, by setting the following in the gradle.properties file.

org.gradle.parallel=true

Using buildtype can improve overall code quality especially if you have multiple config data like server urls.

To override a particular file for a particular build all you have to is create a folder in the src/ directory.

tree