Wednesday, July 1, 2015

Things I wish someone told me when doing Haskell

Hey people,

Long time not posts, yeah i know. Stuck with useless stuff. Finally got some time for a post. This would really be a bundle of snippets mainly for the beginner haskell coders that will soon be frustrated with all the functional elements. I'll try to keep this updated with every new frustration i get :D


Doing IO was the worst thing i had to go through in haskell. As you know that haskell wont allow usual IO in a function, you have to explicitly use do to use a IO command

StdIn as a String

StdIn as an integer/double

Using a function inside a do block with IO

There are instance when our function has to perform IO function only in certain instances. Let's say I need to print numbers only under a certain condition. Then we will have a conditional statement in our function. But as we know every condition in haskell should be complete. If this else ?
For this simply use
return ()
Check this exmaple of printing the pascal triangle


Function defining has several forms and quite different according to what you wanna do.
For an example given here are two ways to define a function that would double the input amount if it's even or keeps the same if it's odd

Note : if is combined with else, otherwise is not combined with it

Friday, January 9, 2015

Function to generate a list of floating point numbers with defined precision in a given range in haskell

Well the top says it all
I'll just put the code here :)

n -  no of precisions
st - starting limit
en - ending limit

Tuesday, December 30, 2014

ExceptionInInitializerError when AsyncTask is used inside a Timer

Hey people,

A quick one here, I was working on a late project and got this weird bug. Tested my android app on 4.2 working all fine but suddenly it crashed on everything below it. Here's the code cause the error

See the problem here is that according to Android Dev, the Async Task MUST run in the UI thread. But the Timer is having it's own seperate thread. So, with the help of Stackoverflow :D I managed a solution where the Timer contains a Handler which would be running in the UI thread. Modified code

Refer for more references

Cya People

Thursday, December 25, 2014

Easily adding animations when Android layout is changed

Hey people,

You wont believe that I spent 1.30 hours on this
Just because i wanted to do some simple animations, like sliding/swiping when a listview of mine is updated :|
If you ever wanted to do something like, pushing list items downwards when adding a new items or pulling the rest of the layout upwards when visibility of some widget changes

just DONT, DO NOT write your own custom animations. Just add the simple property to your activity layout xml file :D yeaah that is all you have to do

Add this to your xml


Thank me Later

Tuesday, December 23, 2014

Error running meteor : Unexpected mongo exit code 1. Restarting.

hey peopple,

yup the title says it, if you have searched for this specific error and came here
i know the feeling bro, FRUSTATED

here's a little background of the issue

* you installed the latest meteor version
* you created a new app
* when you try to run it

Unexpected mongo exit code 1. Restarting.
Unexpected mongo exit code 1. Restarting.
Unexpected mongo exit code 1. Restarting.

3 times in your face

DONT WORRY i got the solution

as i found out on a internet forum, this can be solved by updating your c/c++ compilers uptodate. For some stupid reason mongodb wants it that way. So lets do it.
i am assuming ubuntu environment

  1. sudo add-apt-repository ppa:ubuntu-toolchain-r/test
  2. sudo apt-get update
  3. sudo apt-get install gcc-4.6
  4. sudo apt-get install g++-4.6

and then run the meteor as usual

PS: there's another version of this problem

Unexpected mongo exit code 100. Restarting.

see the error code is 100 not 1
this isnt your error, this error is something related to access violation stuff and you can probably find it in internet everywhere

Happy Meteoring 

Sunday, December 21, 2014

The sidebar and content alignment problem

Spent a fortune of time figuring this out.
You have a sidebar, more like a drawer and you want the rest of the content of site to take full width of the remaining space of the page. Tried float:left float right? NOPE, here's how to do it

Getting VB.NET to work in MonoDevelop [tested in Ubuntu]

Hey follks,

Kinda strange to crash with something totally new to the blog but wth :D. Okay some background first, I recently had to go FULL time ubuntu [not by choice], but because i screwed up my Windows partition. Any how after much more blaaaaas , i wanted to develop C#, VB and ASP stuff for .net framework 4 in UBUNTU.
Strange things i know, but believe me a lot of ppl want to do those. So just like everyone else i searched google, Mono was promising and installed it. [ubuntu 11.10].

When i started Mono, I was really impressed, hell they almost ported VS2010 to ubuntu, the C# features worked great but got dissapointed when i came to the VB.NET section.


When i try to compile the VB.NET code, i get 1 error and 8 warning
8 warnings : the Assemblies not available for some bla
                    cannot find the import GTK
1 error :       Cannot find the 'Windo' class

So there i was searching the internet again and again

Solutions that i found on internet but did not work for me

1) Changing the project type for VS2008 from VS2008
Goto Edit->Preferences->Load/Save
Select VisualStudio 2008 from the dropdown
And recreate a VB.NET project

Well some said it worked but not for me :/

2) Changing the .Net framewrok type
Double click the Porject from Solution Explorer
Build -> General
Runtime Version : Mono / .Net 2.0

Again did not work for me.

And I noticed that the references of the project are all marked red, unlike when i opened a C# project, so after some seriously wasting for time i finally found this.


1) Double click References. You get Edit references dialog
2) Goto .Net Assembly tab
3) Now we are going to add all the DLL files added as references already [but not working] manually again
4) Goto /usr/lib/mono/gac [this is where all the assemblies are]
5) First we'll add the atk-sharp library
     Select atk-sharp->some-directory-with-numbres->atk-sharp.dll
     a reference will be added
6) Repeat the above for other references as well


Now try to compile the project. =VIOLA= :D
working like a baby.
I dont know why those happend but it's working finally, and its really enough for mt

Ill update for any further errors

Cyah all