Posterous theme by Cory Watilo

Filed under: programming

A SED megoldás WOW

Write the shortest program that prints the entire lyrics of "Never Gonna Give You Up" by Rick Astley.

Rules:

  • Must output the lyrics exactly as they appear in the above pastebin. Here's the raw dump: http://pastebin.com/raw.php?i=wwvdjvEj
  • Cannot rely on any external resources - all lyrics must be generated by / embedded in code.
  • No use of existing compression algorithms (e.g. gzip / bzip2) unless you include the full algorithm in your code.
  • Use any language, shortest code wins.

Inteligens dizájn

Epic Epoch Fail

I shit you not:

In the SQLite database in which Apple stores your iPhone text messages, each record has, among other things, a numeric field called 'date'.

If the message in question is an SMS, then that's what you'd expect: the number of seconds since the Unix Epoch, 1-Jan-1970 GMT. But if the message is an MMS or an iMessage, then it's the number of seconds since 1-Jan-2001 GMT. Same field. Same database. All interleaved.

$h->{date} += 978307200 if ($h->{is_madrid});

There is no emoticon for the feeling that I am having right now.

Land of Lisp

So, you still don't think it's worth learning Lisp?

Well, you'll have to make your own decisions on how to make the best use of your valuable free time. However, Lisp really does contain some great programming ideas that you may never encounter anywhere else.

In the interactive comic below (adapted from the epilogue of the book) I've given my best shot at explaining, precisely, what the most interesting features in Lisp are that you'd be missing out on... So why don't you give it a quick read?

Oh, and be sure to click on all the throbbing text!























I do LOVE Vim! part II.

/SELECT$^Mj:.,/DROM~@kb~@kb~@kb~@kbFROM$/ yank m^M?spooo~@kbl^Mmp"mp/SELECT$^Mj/spool SYS^M:.+1,/SELECT/-1 s: .* \([A-Za-z0-9_]\1~@kb+\) *,\?~@kb~@kb:\1|^M?spool^M:.,/SELEX~@kbCT/-1 s:^ ^*~@kb~@kb-~@kb*::^M/spool SYS^M:.+1,/SELECT/-1 join^M:s: ::g^M:s:.*:select '&' from dual ;^M

Ez egy sor. A w regiszter tartalma per pillanat. És most: 2500@w. OMG, működik. Elsőre.

I do LOVE Vim!

/SYSTWO^Myy?SELECT^MOselect '' from dual ;^[0f'p0kf'ld$JxA' from dual;^[Oselect sysd~@kb~@kb~@kb~@kbto_char(sysdate,'YYYYMMDD-HHMISS') from dual;^[/SYST~@kb~@kb~@kb~@kbWHERE^M

Egy baromi hosszú fájlt (nyilván SQL-t) kiegészít némi naplózással. Konkrétan minden lekérdezés elé beszúrja a következő lekérdezés által használt táblát, meg a pontos (bwahaha, mert a céges szerveren pontos az idő, mi?) időt.
Persze az is kell hozzá, hogy a lekérdezések némiképp formázva legyenek. És persze ez egy makró, amit egyszer felvettem, aztán kiadtam a :%s:select to_char:host sync;\r&:, :%s:HHMISS:HH24MISS:g és :set nowrapscan-t és a 1000@q parancsot. Majd hátradőltem. :help recording