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

christma.sh shows a calm animation with a music. It looks like a Christmas card on computer screen.

https://lh3.googleusercontent.com/-bF_h4TGMCvE/Vn3P-fHy55I/AAAAAAAAIu8/81X5epr0Bwc/s800-Ic42/christma.sh.gif

The snowman is adorable with a not-so-little cane. The focal point, the Christmas Tree, stands right in front of you without any snow, it must be a magical tree. Snowing in the background, and smokes come out of chimney, which looks very creative in that ASCII art.

Originally with the first glance, I wished there was a bit of red here and a bit of green there. However, as I look at it more, it doesnt need any colors, simply monochrome does better. Its white and thats Christmas.

christma.sh is written in Bash under the MIT License, currently git-07076bc (2015-12-25) with music Faith Noel (2004) by Trans-Siberian Orchestra.

asciifire burns your terminal, but only 80x25 area. You can change color and/or update interval, or cycle through all five colors through the command-line options.

https://lh3.googleusercontent.com/-CX-hTeVSsnM/VnnFeSP9KCI/AAAAAAAAItM/S9_zEDWASNk/s800-Ic42/asciifire.gif

python asciifire.py -t 1 -d 200000

Itd be a nice screensaver if it can fill entire terminal size, but it doesnt, unfortunately. I attempted, but I failed, but now as I staring at the GIF above, I seem to see the pattern of how it was coded. I can see the fire is shifting to the left with slight changes to each column of fire.

asciifire was created by Matt Hersant on 2013-06-25, written in Python 2 with ncurses under the GPL (version unspecified), currently git-1740a49 (2015-12-11).

tl;dr:

man ascii(7)
man console_codes(4)  # for ANSI escape code

I was looking around and stumbled on this man ascii and I was like dumbfounded, wondering how I could not have known about this.

Why? Because I searched for the Wikipedia pages for ASCII and ANSI escape code. Maybe rarely for ASCII character codes, but quite often for the escape codes whenever I was writing a shell script that would need to move cursor or clear screen, such as blocky.sh.

How I found console_codes, since it doesnt have ANSI nor escape in the title? I searched with [manpage ansi escape code] for a manual page and found that on the first hit. I couldnt believe that I used to go to Wikipedia for those codes, when they are already on my disk all along.

Its funny to think about there is nearly everything on the Internet, the knowledge is vast if you are willing to read, but you dont have to go out to the virtual world, there already is plenty for us to digest inside our computers.

Its like human on Earth, and the universe seems without edges if you consider our knowledge, engineering, and capabilities, but the facts are that we dont even learn a fraction of the planet we are living on, the truth is that we dont even know everything about ourselves, our human body.

2HH                   0AAAAAAAAAAA      1TT          TTT    2EEEEEEEEEEEEEEE
HHH                  AAAAAAAAAAAAAA     TTT          TTT    EEEEEEEEEEEEEEEE
HHH                 AAAA        AAAA    TTT          TTT    EEE
HHH                 AAA          AAA    TTT          TTT    EEE
HHH                 AAA          AAA    TTT          TTT    EEE
HHH                 AAA          AAA    TTT          TTT    EEEEEEEEEEEEEEEP
HHH                 AAA          AAA    TTT          TTT    EEEEEEEEEEEEEEE.
HHH                 AAA          AAA     TTT        TTT     EEE
HHH                 AAA          AAA      TTT      TTT      EEE
HHH                 AAAA        AAAA       TTT    TTT       EEE
HHHHHHHHHHHHHHHH     AAAAAAAAAAAAAA         TTTTTTTT        EEEEEEEEEEEEEEEE
HHHHHHHHHHHHHHH0      AAAAAAAAAAA3            TTT1          EEEEEEEEEEEEEEE7

             o
            /-\
            | |------\
   This is  | |ANY WY|
   Mr. Who  | |------/
       |    | |
       v    | |
     _\|/_  | |
     |o o|  | |     S
     |_v_|  | |     !
       |    | |    (-)
     /---\  | |   (---)
  /-|     |=======~~~~~o
  | |     | | |
Copyright 2010 Yu-Jie Lin

        _________________________________________
       /.                 / /                   /
      / .                / /                   /|
     /  .               / /   \_|_/           / |
    /   .              / /   ( . . )         /  |
   /    .             / /     \___/         /   |
  /     .            / /     ___I___       /    |
 /      .           / /     /       \     /     |
/__________________/ /____/=|  /\/\ |=\__/      |
|       .          | |    | |  \  / | |  |      |
|       .          | |    | |   \/  | |  |      |
|       .           ~     | |       | |  |      |
|       .                 m \-------/ m  |      |
|       .                     || ||      |      |
|       ......................||.||......|......|
|      .                      || ||      |      /
|     .                       || ||      |     /
|    .                        || ||      |    /
|   .                        /--v--\     |   /
|  .                                     |  /  /\/\
| .                                      | /   \\//   (c) 2010
|________________________________________|/     \/  Yu-Jie Lin

Today, Last Tweets run into another issue. It's about the encoding

d = {'msg': u'Is still rather 17\xb0 in Auckland.Brr'}
print d['msg']
# Is still rather 17 in Auckland.Brr
print pickle.dumps(d, 0)
# "(dp0\nS'msg'\np1\nVIs still rather 17\xb0 in Auckland.Brr\np2\ns."

As you can see \xb0 is not in ASCII. If you assign the pickled result to a db.TextProperty[link], you will see an track back like

pickle.dumps(d, 0).decode('ascii')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
UnicodeDecodeError: 'ascii' codec can't decode byte 0xb0 in position 34: ordinal not in range(128)
TextProperty will try to decode with ASCII decoder if you assign a str.

A bigger character set can resolve this issue:

print pickle.dumps(d, 0).decode('latin-1')
# u"(dp0\nS'msg'\np1\nVIs still rather 17\xb0 in Auckland.Brr\np2\ns."
to_db = pickle.dumps(d, 0).decode('latin-1')
print pickle.loads(to_db.encode('latin-1'))
# {'msg': u'Is still rather 17\xb0 in Auckland.Brr'}
print pickle.loads(to_db.encode('latin-1'))['msg']
# Is still rather 17 in Auckland.Brr

An working code should look like:

model.my_text = db.Text(pickle.dumps(my_dict), encoding='latin-1') 
When this model try to set my_text, it sees a type db.Text object. It won't try to decode. I think you can also give an type unicode object directly (not tested):
model.my_text = pickle.dumps(my_dict).decode('latin-1')