haskell

[Haskell] Import/unimport a module into ghci

Problem

Import/Unimport a module on ghci.

Solution

To import:

:module +<name of the module>

To unimport:

:module -<name of the module>

Shortcut for :module is :m

Examples:

Import Data.Int module:

:module +Data.Int

or

:module +Data.Int

Unimport Data.Int module:

:module -Data.Int
linux · tip

[Linux] xclip command

Copying

The following command

echo "foo" | xclip -selection clipboard

will copy “foo” to you clipboard. Try pasting it elsewhere. The clipboard selection is the one used by Ctrl-C Ctrl-V commands. The default selection of xclip is the one used when you select text in linux (XA_PRIMARY).

A shorter version would be:

echo "foo" | xclip -sel c

Pasting

You can also send the contents of the current clipboard to the terminal (useful for piping).

xclip -sel c -out

Or

xclip -sel c -o

eclipse

[Eclipse] Find all occurrences where a variable is written

Problem

Search all occurrences where a given variable is written (but not read) in a workspace, using Eclipse.

Solution

Search for current references (Shortcut: Ctrl + Shift + G) and filter out occurrences by type using the menu illustrated in the image below. In this case, it’d probably suffice to check the ‘Read’ entry.

Reference

[1] http://stackoverflow.com/questions/9333634/find-all-assignments-to-variable

eclipse

[Eclipse] Finding the opening bracket at a closing one

Problem

The method/loop you’re reading is very long and you after a while you see a lot of closing brakets and it’s difficult to tell to which opening bracket it matches to.

Solution

Place the cursor at the right of the closing bracket and use the following shortcut:

Ctrl + Shift + P

Or (for Mac)

Cmd + Shift + P

PS. In Eclipse 3.8 a new feature is expected to help in this task.

References

[1] http://stackoverflow.com/questions/1910836/show-function-statement-declaration-after-selecting-closing-brace-in-eclipse

applet

[Java] Passing parameters to Java applets

Problem

How to pass parameters to a Java applet?

Solution

You can specify the parameters in the calling HTML this way:

<applet code="my.Applet.class" width="600" height="400" >
    <param name="param1" value="value1" />
    <param name="param2" value="value2" />
</applet>

Then, the Applet class (from which your applet class extends) has a method getParameter(). In this case, getParameter("param1") would return the String "value1".

eclipse

[Eclipse] Problem downloading plugins

Problem

Problem downloading plugins in Eclipse

Solution

I had to solve two issues. First, since I was behind a proxy server, I had to set up the authentication as described here.

After that I was still not able to download plugins and the reason was that my connection was very slow and the downloading was timing out. The solution to this is to follow the first answer of this question.