As of 2016-02-26, there will be no more posts for this blog. s/blog/pba/
Showing posts with label Valentines Day. Show all posts

The idea came from a bye-bye-message Happy Valentines Day I left in this screencast1 while I played Kina Giannis Valentine with MPD. Few hours ago, I recalled I have written falling hearts script using JavaScript for webpages. Why not another one for terminal?

So, I started to write one, two hours later, I have a working code. A break later and an hour more, it gave me a BIG <3!

Here is a video.

I didnt draw that heart but downloaded an ASCII-art from some website (link is included in source code). I was thinking to have variable size based on terminal window size, but didnt want to kill too many my brain cells, so I just found one and rendered it in same size. I also thought about randomly rendering medium size of hearts, so it would look like more of a screensaver, and that is what I want this script to be. However, I did code for that after I added !

[1] is gone.

1   Download

You can download the Bash script, falling-< (New BSD License), on Google Code.

2   Configuration

Please open the source code and change variables. It should work out-of-the-box if your terminal supports 256 color mode; if not, comment out about line the mode.

3   Keys

  • L: Toggle the !
  • Q or Ctrl+C: Exit the script.

4   x1,000,000?

If you want to add more functions, go ahead! Send me a heartch! [patch]

I was window shopping at Community Contribution of Arch Linux Fourms for totally free new application, tried to see if I can find new toy. I saw this HC, after I read and saw some examples the author posted, I decided to give it a try.

1   Happy Valentines Day!

Too early? or too late?


2   No recursion? You cant stop me!

If you try to define a recursion function, you will get:

Error : recursive definition.

Lets trick HC!


Some outputs:

> fib(10)==fibo(10)
> fib(70)
Error : too much recursion/nestedness. If you know what you are doing, you can bypass this with:
Argument Error : if() : at least two arguments are needed (condition, true_branch, false_branch)
> \bpn
By pass is now on.
> fib(70)

You will have to wait until only God knows how long it takes


Now, HC is allowed to define recursion function:

fib(n) = if(n<2,n,fib(n-1)+fib(n-2))

, read more. (2010-08-24)

3   FFT! The FFT!?

Yes, the Fast Fourier transform!



> x = [1,0,3i-3,4i5,5]
> fft(x)

Confirmed by result from SciPy:

>>> import scipy
>>> scipy.fft([1,0,3-3j,4+5j,5])
array([ 13.00000000+2.j        ,  -7.82031601+3.72503385j,
         6.72648612+2.60590373j,  -8.49041814-1.36983576j,

Note: the representations of complex number are different.


Here is a shorter version:



The result can be retrieved by y.

4   Conclusion

This is a great CLI program, I am going to replace SpeedCrunch. You can do some simple programming, though I found its still limited. (What do you expect? Signal processing using a calculator?) When I installed SpeedCrunch because I wanted one can allow me to easy input, bc is not so friendly, even I prefer CLI over GUI. Now, HC can do things I need and its a CLI and its resource-friendly. Definitely the top choice for me!

It has vector but its not much you can do with it at this moment, but if you just use it for 1+1, it can do much more than that. If you dont like CLI, dont worry, it provides GUI as well. But I didnt try it, so no comments on that.

If you are a terminal user, you might want to check out "Time to have Falling Hearts screensaver for geek's terminal ."
I saw someone asked in discussion group, so I decided to write on my own. Here is all you need:
<script type="text/javascript" src=""></script>
<script type="text/javascript" src=""></script>

Put these two lines to an HTML/JavaScript gadget without setting the title of widget. You should now have falling hearts! <3

You can see them in this demo page. The code is released under the modified BSD.

There will be 40 hearts, flying around, fading at bottom, then starting falling over again. They also slightly change font size and change colors. Those hearts are text, actually just HTML entity &hearts;.

The script currently doesn't let you customize easily. If you want to, you need to download the script, change variables and upload to somewhere else.

Feel free to provide ideas if you need to fit your needs.

Hope you would <3 it!