Ok,
1) Create an account on aws.amazon.com, you will need a credit card to enter but you won't be charged that's for security purposes.
2) Hover your mouse over My Account / Console, click AWS Management Console. This will take you to https://console.aws.amazon.com/
3) Click on EC2, This will take you to https://console.aws.amazon.com/ec2/
4) On the left pane of the screen click on Key Pairs. Click Create Key Pair. Enter a name for your key click create. Your key -pair will be created and your private key will start downloading. Save it at a safe place.
5) Get back to EC2 Console https://console.aws.amazon.com/ec2 Click on Launch Instance, this will take you to https://console.aws.amazon.com/ec2/home?region=us-west-2#startWizards=true
6) Quick Launch Wizard > Choose a Launch Configuration, scroll down
May 20, 2013
Make Java Memory Efficient
1. in getting substrings from a BIG string make a new string like here:
String mySubstring = new String(orig.split(";")[i]);
If you don't mind sacrificing a little accuracy vs more memory efficeiency use bloomfilter instead of hashmap.
Taken from here and here.
Use efficient designs: stuff like Flyweight Pattern! مگس وزن
use as many abstractions as you can, don't worry about it, it would pay off
I didn't know there is a method called intern for String! Note that
String mySubstring = new String(orig.split(";")[i]);
OR new String(offset + beginIndex, endIndex - beginIndex, value);
Taken from here and here.If you don't mind sacrificing a little accuracy vs more memory efficeiency use bloomfilter instead of hashmap.
Taken from here and here.
Use efficient designs: stuff like Flyweight Pattern! مگس وزن
use as many abstractions as you can, don't worry about it, it would pay off
I didn't know there is a method called intern for String! Note that
May 19, 2013
How to master your tmux like a BOSS! Generate tmux panes
Here is a killer point! Whatever you do with your tmux call
$ tmux source-file .tmux.conf
So I was monitoring several processes on a server from my laptop and whenever I connected to an ssh and lost my connection my tmux would freeze and I had to rebuild the whole structure:
First row:
$ tmux source-file .tmux.conf
So I was monitoring several processes on a server from my laptop and whenever I connected to an ssh and lost my connection my tmux would freeze and I had to rebuild the whole structure:
First row:
May 18, 2013
Why Java Calculates Date Time Wrong
I needed to iterate through a date-time range and observed some strange behavior from Java. So I want to iterate hour by hour from 2011-10-05-00 until 2013-02-13-23. The code I was expecting was
For some strange reason that I haven't figured out yet this will iterate from 2011-10-05-00 until 2013-03-13 23 (one month later than I'd expected!).
Parse the string first!
DateFormat format = new SimpleDateFormat("yyyy-MM-dd HH");
Calendar c = new GregorianCalendar(2011, 10, 5, 0, 0);
Calendar cEnd = new GregorianCalendar(2013, 2, 14, 00, 0);
while (c.getTime().before(cEnd.getTime())) {
System.out.print(format.format(c.getTime()) + "[");
System.out.println(c.getTimeInMillis() + "](" + cEnd.getTimeInMillis() + ")");
c.add(Calendar.HOUR, 1);
}
For some strange reason that I haven't figured out yet this will iterate from 2011-10-05-00 until 2013-03-13 23 (one month later than I'd expected!).
Parse the string first!
May 10, 2013
Vim colorscheme Mustang
I was having some issues setting up a custom color scheme for vim.
Download a colorsheme e.g. mustang from here move it to ~/.vim/colors
In your ~/.vimrc add line
colorscheme mustang
I was getting
Error detected while processing /home/morteza/.vimrc:
line 2:
E185: Cannot find color scheme mustang
Press ENTER or type command to continue
Download a colorsheme e.g. mustang from here move it to ~/.vim/colors
In your ~/.vimrc add line
colorscheme mustang
I was getting
Error detected while processing /home/morteza/.vimrc:
line 2:
E185: Cannot find color scheme mustang
Press ENTER or type command to continue
To fix this rename
What if your connection drops while you are in the middle of SSH?
If your connection drops in the middle of an ssh session, the TTL of your session will terminate your job running via that session after a while. To avoid
May 1, 2013
Java CPU/Memory Heap Usage Monitoring A.K.A. Java Profiling
Java Profiling: One of the important tools needed when working with java is the use of profiling tools to tell you about the memory consumption and CPU usage of each method. VisualVM is a free and easy to use tool. Java profiling will tell you how heap is being used, Garbage Collector operations, threads activities, CPU time of each method, which object is taking most of memory and etc.
To set it up
To set it up
April 18, 2013
How to master git rebase like a boss!
once your work on the forked project is done, then is the time to get everything back to the upstream.
$ git fetch upstream; git checkout master; git rebase upstream/master
if everything is ok this will go through hands-down. if there are merge conflicts you will be prompted, then
$ git rebase --continue; git rebase --skip; git mergetool
also every once in a while execute the following command to get rid of the .orig files that would appear after a merge
$ find . -name "*.orig" -print0 | xargs -0 rm
note: You can use kdiff3 as your merge tool.
More on Git
$ git fetch upstream; git checkout master; git rebase upstream/master
if everything is ok this will go through hands-down. if there are merge conflicts you will be prompted, then
$ git rebase --continue; git rebase --skip; git mergetool
also every once in a while execute the following command to get rid of the .orig files that would appear after a merge
$ find . -name "*.orig" -print0 | xargs -0 rm
note: You can use kdiff3 as your merge tool.
More on Git
March 29, 2013
Java and Closures
I found that java is in the process of adding function closures (function as first class citizen) to its syntax.
Here is a good example
Here is a good example
March 25, 2013
How to check Scala/Java in real Bytecode?
Imagine you have the following code in AntiTailRecursive.scala
object bc {
def factorial(n: BigInt): BigInt = {
if (n == 0)
1
else {
//n*factorial(n-1)
val t1 = n - 1
val t2 = factorial(t1)
n * t2
}
}
def main(args: Array[String]): Unit = {
println(factorial(5))
}
}
$ scalac AntiTailRecursive.scala #compile the code $ scala b # verify that the code works $ javap -l -p -c -v b #To view the java byte code of this scala source code/class:
March 24, 2013
Alternative Way to Master Ubuntu
Recently I found some new tools that make you a master using linux specially ubuntu.
Try Krusader which is a file manager instead of Nautilus. Nautilus is cool but doesn't give you the feelign fo a good file manager.
Krudsader benefits:
tools to compare files,
open terminal here,
Try Krusader which is a file manager instead of Nautilus. Nautilus is cool but doesn't give you the feelign fo a good file manager.
Krudsader benefits:
tools to compare files,
open terminal here,
March 6, 2013
Peer-to-Peer Command-Line Chat in Go Lang
I just implemented a peer to peer (p2p) command-line chat in Go language version as an example to start with. I start to like Go!
You can view the source code here on Github: https://github.com/mshahriarinia/Golang/blob/master/p2pChat/src/node.go
Some notes :
1. Spent quite some time on finding and setting up debuggers
You can view the source code here on Github: https://github.com/mshahriarinia/Golang/blob/master/p2pChat/src/node.go
Some notes :
1. Spent quite some time on finding and setting up debuggers
Subscribe to:
Posts (Atom)
