## Lots of hearts on letters

You Just Lost?

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

< Yep, just click it! Or wait on Valentines Day.

The idea came from a bye-bye-message *Happy Valentines Day* I left in this screencast^{1} 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] | http://www.youtube.com/watch?v=2SA73WoRJGE is gone. |

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

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.

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

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

calculator graph mathematics recursion science Valentines Day

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.

Too early? or too late?

r(t)=2-2sin(t)+sin(t)*sqrt(abs(cos(t)))/(sin(t)+1.4) graphpeq(r(t)*cos(t),r(t)*sin(t),0,2pi,-3,3,-4,1)

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

fib(n)=if(n>=0, if(n==0,0, if(n==1,1, fib(n-1)+fib(n-2) ) ) ) Error : recursive definition.

Lets trick HC!

fibr(n)=fib(n) fib(n)=if(n>=0, if(n==0,0, if(n==1,1, fibr(n-1)+fibr(n-2) ) ) )

Some outputs:

> fib(10)==fibo(10) 1 > fib(70) Error : too much recursion/nestedness. If you know what you are doing, you can bypass this with: \bpn. 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

Note

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)

Yes, the Fast Fourier transform!

fft(x)=for(k=0,k<length(x),k+=1, xk=0; for(j=0,j<length(x),j+=1, a=x[j]; b=exp(-2pi*k*j*0i1/length(x)); xk+=a*b; ); print(xk); )

Example:

> x = [1,0,3i-3,4i5,5] > fft(x) 13i2 -7.8203160070896799i3.7250338450183462 6.7264861191111235i2.6059037339171068 -8.4904181416113337i-1.3698357564173172 1.5842480295898901i-6.9611018225181358

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, 1.58424803-6.96110182j])</pre>

Note: the representations of complex number are different.

Note

Here is a shorter version:

fft(x)=for(k=0,k<length(x),k+=1, for(j=0,j<length(x),j+=1, a=x[j]; b=exp(-2pi*k*j*0i1/length(x)); xk=if(j==0,a*b,xk+a*b); ); y=if(k==0,[xk],join(y,[xk])); )

(2010-08-24)

The result can be retrieved by `y`.

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.

falling heart JavaScript love The B Thing (old blog) Valentines Day

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="http://www.google.com/jsapi"></script>`

<script type="text/javascript" src="http://yjl.googlecode.com/svn/trunk/JavaScript/falling_hearts.js"></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 ♥.

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!

Subscribe to:
Posts (Atom)