Cooler ASCII Spinners? [closed] - user-interface
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 years ago.
Improve this question
In a console app, an ascii spinner can be used, like the GUI wait cursor, to indicate that work is being done. A common spinner cycles through these 4 characters: '|', '/', '-', '\'
What are some other cyclical animation sequences to spice up a console application?
Lots of choices with Unicode, including ⌚ and ⌛!
← ↖ ↑ ↗ → ↘ ↓ ↙
▁ ▂ ▃ ▄ ▅ ▆ ▇ █ ▇ ▆ ▅ ▄ ▃ ▁
▉▊▋▌▍▎▏▎▍▌▋▊▉
▖ ▘ ▝ ▗
┤ ┘ ┴ └ ├ ┌ ┬ ┐
◢ ◣ ◤ ◥
◰ ◳ ◲ ◱
◴ ◷ ◶ ◵
◐ ◓ ◑ ◒
◡◡ ⊙⊙ ◠◠
⣾⣽⣻⢿⡿⣟⣯⣷ ⠁⠂⠄⡀⢀⠠⠐⠈ The entire braille block, even in random order http://www.fileformat.info/info/unicode/block/braille_patterns/images.htm
Watch them in action here:
var nl = "\r\n";
var spinners = [
"←↖↑↗→↘↓↙",
"▁▃▄▅▆▇█▇▆▅▄▃",
"▉▊▋▌▍▎▏▎▍▌▋▊▉",
"▖▘▝▗",
"▌▀▐▄",
"┤┘┴└├┌┬┐",
"◢◣◤◥",
"◰◳◲◱",
"◴◷◶◵",
"◐◓◑◒",
"|/-\\",
".oO#*", ["◡◡", "⊙⊙", "◠◠"],
["◜ ", " ◝", " ◞", "◟ "],
"◇◈◆",
"⣾⣽⣻⢿⡿⣟⣯⣷",
"⡀⡁⡂⡃⡄⡅⡆⡇⡈⡉⡊⡋⡌⡍⡎⡏⡐⡑⡒⡓⡔⡕⡖⡗⡘⡙⡚⡛⡜⡝⡞⡟⡠⡡⡢⡣⡤⡥⡦⡧⡨⡩⡪⡫⡬⡭⡮⡯⡰⡱⡲⡳⡴⡵⡶⡷⡸⡹⡺⡻⡼⡽⡾⡿⢀⢁⢂⢃⢄⢅⢆⢇⢈⢉⢊⢋⢌⢍⢎⢏⢐⢑⢒⢓⢔⢕⢖⢗⢘⢙⢚⢛⢜⢝⢞⢟⢠⢡⢢⢣⢤⢥⢦⢧⢨⢩⢪⢫⢬⢭⢮⢯⢰⢱⢲⢳⢴⢵⢶⢷⢸⢹⢺⢻⢼⢽⢾⢿⣀⣁⣂⣃⣄⣅⣆⣇⣈⣉⣊⣋⣌⣍⣎⣏⣐⣑⣒⣓⣔⣕⣖⣗⣘⣙⣚⣛⣜⣝⣞⣟⣠⣡⣢⣣⣤⣥⣦⣧⣨⣩⣪⣫⣬⣭⣮⣯⣰⣱⣲⣳⣴⣵⣶⣷⣸⣹⣺⣻⣼⣽⣾⣿",
"⠁⠂⠄⡀⢀⠠⠐⠈", [">))'>", " >))'>", " >))'>", " >))'>", " >))'>", " <'((<", " <'((<", " <'((<"],
[" /\\O\n /\\/\n /\\\n / \\\n LOL LOL", " _O\n //|_\n |\n /|\n LLOL", " O\n /_\n |\\\n / |\n LOLLOL"],
[
"╔════╤╤╤╤════╗\n║ │││ \\ ║\n║ │││ O ║\n║ OOO ║",
"╔════╤╤╤╤════╗\n║ ││││ ║\n║ ││││ ║\n║ OOOO ║",
"╔════╤╤╤╤════╗\n║ / │││ ║\n║ O │││ ║\n║ OOO ║",
"╔════╤╤╤╤════╗\n║ ││││ ║\n║ ││││ ║\n║ OOOO ║"
],
[
" "+nl+
" "+nl+
" "+nl+
" "+nl+
" '\\"+nl+
" ' \\===%^,"+nl+
" ' \\# >"+nl+
" ' `\\/> _"+nl+
" ' ______>,^____\\"+nl+
" ' \\-=-=-=-=-=-/{}"+nl+
"'~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~"+nl+
"~ejm97~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-",
" "+nl+
" "+nl+
" "+nl+
" "+nl+
" '\\"+nl+
" ' \\===%^,"+nl+
" ' \\# >"+nl+
" ' `\\/> _"+nl+
" ' ______>,^____\\"+nl+
" ' \\-=-=-=-=-=-/{}"+nl+
"'-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-"+nl+
"-ejm97-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~",
" "+nl+
" "+nl+
" "+nl+
" "+nl+
" '\\"+nl+
" ' \\===%^,"+nl+
" ' \\# >"+nl+
" ' `\\/> _"+nl+
" ' ______>,^____\\"+nl+
" ' \\-=-=-=-=-=-/{}"+nl+
"'~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~"+nl+
"~ejm97~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-",
" "+nl+
" "+nl+
" "+nl+
" "+nl+
" '\\"+nl+
" ' \\===%^,"+nl+
" ' \\# >"+nl+
" ' `\\/> _"+nl+
" ' ______>,^____\\"+nl+
" ' \\-=-=-=-=-=-/{}"+nl+
"'-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-"+nl+
"-ejm97-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~",
" "+nl+
" "+nl+
" "+nl+
" "+nl+
" '\\"+nl+
" ' \\===%^,"+nl+
" ' \\# >"+nl+
" ' `\\/> _"+nl+
" ' ______>,^____\\"+nl+
" ' \\-=-=-=-=-=-/{}"+nl+
"'~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~"+nl+
"~ejm97~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-",
" "+nl+
" "+nl+
" "+nl+
" "+nl+
" '\\"+nl+
" ' \\ ==%^,"+nl+
" ' \\# >"+nl+
" ' `\\/> _"+nl+
" ' ______>,^____\\"+nl+
" ' \\-=-=-=-=-=-/{}"+nl+
"'-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-"+nl+
"-ejm97-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~",
" "+nl+
" "+nl+
" "+nl+
" "+nl+
" '\\"+nl+
" ' \\ =%^,"+nl+
" ' \\# >"+nl+
" ' `\\/> _"+nl+
" ' ______>,^____\\"+nl+
" ' \\-=-=-=-=-=-/{}"+nl+
"'~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~"+nl+
"~ejm97~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-",
" "+nl+
" "+nl+
" "+nl+
" "+nl+
" '\\"+nl+
" ' \\ %^,"+nl+
" ' \\# >"+nl+
" ' `\\/> _"+nl+
" ' ______>,^____\\"+nl+
" ' \\-=-=-=-=-=-/{}"+nl+
"'-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-"+nl+
"-ejm97-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~",
" "+nl+
" "+nl+
" "+nl+
" "+nl+
" '\\"+nl+
" ' \\ ,^%"+nl+
" ' \\# <"+nl+
" ' `\\/> _"+nl+
" ' ______>,^____\\"+nl+
" ' \\-=-=-=-=-=-/{}"+nl+
"'~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~"+nl+
"~ejm97~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-",
" "+nl+
" "+nl+
" "+nl+
" "+nl+
" '\\"+nl+
" ' \\ ,^%="+nl+
" ' \\# <"+nl+
" ' `\\/> _"+nl+
" ' ______>,^____\\"+nl+
" ' \\-=-=-=-=-=-/{}"+nl+
"'-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-"+nl+
"-ejm97-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~",
" "+nl+
" "+nl+
" "+nl+
" "+nl+
" '\\"+nl+
" ' \\ ,^%=="+nl+
" ' \\# <"+nl+
" ' `\\/> _"+nl+
" ' ______>,^____\\"+nl+
" ' \\-=-=-=-=-=-/{}"+nl+
"'~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~"+nl+
"~ejm97~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-",
" "+nl+
" "+nl+
" "+nl+
" "+nl+
" '\\"+nl+
" ' \\ ,^%==="+nl+
" ' \\# <"+nl+
" ' `\\/> _"+nl+
" ' ______>,^____\\"+nl+
" ' \\-=-=-=-=-=-/{}"+nl+
"'-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-"+nl+
"-ejm97-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~",
" "+nl+
" "+nl+
" "+nl+
" "+nl+
" '\\"+nl+
" ' \\ ,^%==="+nl+
" ' \\# <"+nl+
" ' `\\/> _"+nl+
" ' ______>,^____\\"+nl+
" ' \\-=-=-=-=-=-/{}"+nl+
"-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~"+nl+
"~ejm97~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-",
" "+nl+
" "+nl+
" "+nl+
" "+nl+
" '\\"+nl+
" ' \\ ,^%==="+nl+
" ' \\# <"+nl+
" ' `\\/> _"+nl+
" ______>,^____\\"+nl+
" \\-=-=-=-=-=-/{}"+nl+
"~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-"+nl+
"-ejm97-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~",
" "+nl+
" "+nl+
" "+nl+
" "+nl+
" '\\"+nl+
" ' \\ ,^%==="+nl+
" ' \\# <"+nl+
" ' `\\/> _"+nl+
" ______>,^____\\"+nl+
" \\-=-=-=-=-=-/{}"+nl+
"-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~"+nl+
"~ejm97~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-",
" "+nl+
" "+nl+
" "+nl+
" "+nl+
" '|"+nl+
" ' | ,^%---"+nl+
" ' |# < \\"+nl+
" ' `\\/> _"+nl+
" ______>,^____\\"+nl+
" \\-=-=-=-=-=-/{}"+nl+
"~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-"+nl+
"-ejm97-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~",
" "+nl+
" "+nl+
" "+nl+
" "+nl+
" '/"+nl+
" ' / ,^%---"+nl+
" ' /# < \\"+nl+
" ' `\\/> _"+nl+
" ______>,^____\\"+nl+
" \\-=-=-=-=-=-/{}"+nl+
"-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~"+nl+
"~ejm97~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-",
" "+nl+
" "+nl+
" "+nl+
" "+nl+
" '|"+nl+
" ' | ,^%---"+nl+
" ' |# < \\"+nl+
" ' `\\/> _"+nl+
" ______>,^____\\"+nl+
" \\-=-=-=-=-=-/{}"+nl+
"~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-"+nl+
"-ejm97-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~",
" "+nl+
" "+nl+
" "+nl+
" "+nl+
" '/"+nl+
" ' / ,^%---"+nl+
" ' /# < \\"+nl+
" ' `\\/> _"+nl+
" ______>,^____\\"+nl+
" \\-=-=-=-=-=-/{}"+nl+
"-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~"+nl+
"~ejm97~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-",
" "+nl+
" "+nl+
" "+nl+
" "+nl+
" '/"+nl+
" ' / ,^%---"+nl+
" ' /# < \\"+nl+
" ' `\\/> _"+nl+
" ______>,^____\\"+nl+
" \\-=-=-=-=-=-/{}"+nl+
"~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-"+nl+
"-ejm97-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~",
" "+nl+
" "+nl+
" "+nl+
" "+nl+
" '|"+nl+
" ' / ,^%---"+nl+
" ' /# < \\"+nl+
" ' `\\/> _"+nl+
" _______>,^___\\"+nl+
" \\-=-=-=-=-=-/{}"+nl+
"-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~"+nl+
"~ejm97~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-",
" "+nl+
" "+nl+
" "+nl+
" "+nl+
" '\\"+nl+
" ' | ,^%---"+nl+
" ' /# < \\"+nl+
" ' `\\/> _"+nl+
" ________>,^__\\"+nl+
" \\-=-=-=-=-=-/{}"+nl+
"~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-"+nl+
"-ejm97-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~",
" "+nl+
" "+nl+
" "+nl+
" "+nl+
" '|"+nl+
" ' / ,^%---"+nl+
" ' /# < \\"+nl+
" ' `\\/> _"+nl+
" _______>,^___\\"+nl+
" \\-=-=-=-=-=-/{}"+nl+
"-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~"+nl+
"~ejm97~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-",
" "+nl+
" "+nl+
" "+nl+
" "+nl+
" '\\"+nl+
" ' | ,^%---"+nl+
" ' /# < \\"+nl+
" ' `\\/> _"+nl+
" ________>,^__\\"+nl+
" \\-=-=-=-=-=-/{}"+nl+
"~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-"+nl+
"-ejm97-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~",
" "+nl+
" "+nl+
" "+nl+
" "+nl+
"' '/"+nl+
" ' ' / \\_,^%---"+nl+
" ' ' /# < \\"+nl+
" `\\/> _"+nl+
" ________>,^__\\"+nl+
" \\-=-=-=-=-=-/{}"+nl+
"-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~"+nl+
"~ejm97~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-",
" "+nl+
" "+nl+
" "+nl+
";''"+nl+
" ' '/ /"+nl+
" ' ' / \\,^%==="+nl+
" ' ' /# <"+nl+
" `\\/> _"+nl+
" ________>,^__\\"+nl+
" \\-=-=-=-=-=-/{}"+nl+
"~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-"+nl+
"-ejm97-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~",
" "+nl+
" "+nl+
" "+nl+
" ;''"+nl+
" ' '/ /"+nl+
" ' ' / \\,^%==="+nl+
" ' ' /# <"+nl+
" `\\/> _"+nl+
" ________>,^__\\"+nl+
" \\-=-=-=-=-=-/{}"+nl+
"-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~"+nl+
"~ejm97~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-",
" "+nl+
" "+nl+
" ;''"+nl+
" '"+nl+
" ' '/ /"+nl+
" ' ' / \\,^%==="+nl+
" /# <"+nl+
" `\\/> _"+nl+
" ________>,^__\\"+nl+
" \\-=-=-=-=-=-/{}"+nl+
"~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-"+nl+
"-ejm97-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~",
" "+nl+
" "+nl+
" ;'"+nl+
" '"+nl+
" ' '/ /"+nl+
" ' ' / \\,^%=="+nl+
" /# <"+nl+
" `\\/> _"+nl+
" ________>,^__\\"+nl+
" \\-=-=-=-=-=-/{}"+nl+
"-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~"+nl+
"~ejm97~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-",
" "+nl+
" "+nl+
" ; "+nl+
" '"+nl+
" ' '/ /"+nl+
" ' ' / \\,^%="+nl+
" /# <"+nl+
" `\\/> _"+nl+
" ________>,^__\\"+nl+
" \\-=-=-=-=-=-/{}"+nl+
"~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-"+nl+
"-ejm97-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~",
" "+nl+
" "+nl+
" "+nl+
"'. ;'."+nl+
" '- .' '/ _"+nl+
"*) / ' ' / \\=%"+nl+
" _\\ ' ' /# >"+nl+
"'~ `\\/> _"+nl+
" ________>,^__\\"+nl+
" \\-=-=-=-=-=-/{}"+nl+
"-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~"+nl+
"~ejm97~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-",
" "+nl+
" "+nl+
"`-."+nl+
" '. ;"+nl+
" '- . ' '/_"+nl+
"{ (*) / ' ' / \\==#^"+nl+
" _\\ ' ' /# >"+nl+
".;;'~ `\\/> _"+nl+
" ________>,^__\\"+nl+
" \\-=-=-=-=-=-/{}"+nl+
"~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-"+nl+
"-ejm97-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~",
" "+nl+
" \\\\\\\\"+nl+
".-' `-. ;"+nl+
" '.'"+nl+
" '- '|"+nl+
" {{ (*) / '' |===#^"+nl+
" _\\ |# >"+nl+
" .;;'~ `\\/> _"+nl+
"/~~''~ ________>,^__\\"+nl+
" \\-=-=-=-=-=-/{}"+nl+
"-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~"+nl+
"~ejm97~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-",
" "+nl+
" \\\\\\\\ ;"+nl+
" .-' `-. '"+nl+
" .-' '. ''"+nl+
" .' '- \\"+nl+
"' {{ (*) /===#^,/"+nl+
"-. _\\ >"+nl+
" ~-. .;;'~|# \\/> _"+nl+
" ///~~''~______`__>,^_\\"+nl+
" \\-=-=-=-=-=-/{}"+nl+
"~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-"+nl+
"-ejm97-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~",
" "+nl+
" \\\\\\\\ "+nl+
" .-' `-."+nl+
" .-' '."+nl+
" .' '- \\"+nl+
"(`-.-' {{ (*) / ===#^,/"+nl+
" } .'~-. _\\/ >"+nl+
" (/ ~-. .;;'~ / \\/> "+nl+
" ///~''~_____/#____>,^"+nl+
" \\-=-=-`-=-=-/{}"+nl+
"-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~"+nl+
"~ejm97~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-",
" "+nl+
" "+nl+
" \\\\\\\\ YIKES"+nl+
" .-' `-."+nl+
" .-' '. /"+nl+
" .' '- ---#^,/"+nl+
" (`-.-' {{ (*) / / >"+nl+
" } .'~-. _\\ \\/> "+nl+
" (/ ~-. .;;'~_____>,^"+nl+
" ///~''~-=-=|#-=-=-/{}"+nl+
"~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-"+nl+
"-ejm97-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~",
" "+nl+
" "+nl+
" YIKES"+nl+
" \\\\\\\\"+nl+
" .-' `-. \\"+nl+
" .-' '. ---#^,/"+nl+
" .' '- / >"+nl+
" (`-.-' {{ (*) / \\/> "+nl+
" } .'~-. _\\___>,^"+nl+
" (/ ~-. .;;'~/=-=-=-/{}"+nl+
"-~-~-~-~-~-~-~-~-~-~-~/#-~-~-~-~-~-~"+nl+
"~ejm97~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-",
" "+nl+
" "+nl+
" YIKES"+nl+
" "+nl+
" \\\\\\\\ _"+nl+
" .-' `-. ---#^,/"+nl+
" .-' '. / >"+nl+
" .' '- \\/> "+nl+
" (`-.-' . . ` {{ (*) /___>,^"+nl+
" } .'~-. . ` _\\-=-=-/{}"+nl+
"~-~-~-~-~-~-~-~-~-~-~-/-~-~-~-~-~-~-"+nl+
"-ejm97-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~",
" "+nl+
" "+nl+
" YIKES"+nl+
" "+nl+
" _"+nl+
" ` . \\\\\\\\ ---#^,/"+nl+
" ` ` .-' `-. . '/ >"+nl+
" ` .-' '. ' \\/> "+nl+
" `' ` '-___>,^"+nl+
" (`-.-' . . ` {{ (*) /-=-=-/{}"+nl+
"-~-~-~-~-~-~-`-. . ` ' \\~-~-~-~-~-~"+nl+
"~ejm97~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-",
" "+nl+
" "+nl+
" YIKES"+nl+
" "+nl+
" _"+nl+
" ` . ' ---=^,/"+nl+
" ` ` . . / >"+nl+
" ` ` \\\\\\\\ ' \\/> "+nl+
" ` ` .-' `-. ______>,^"+nl+
" ` .-' '.-=-=-=-/{}"+nl+
"~-~-~-~-~-.-~-~-~-'-~-~-~-~-~-~-~-~-"+nl+
"-ejm97-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~",
" "+nl+
" "+nl+
" YIKES"+nl+
" "+nl+
"` . ' _"+nl+
" ` ` ---#^,/"+nl+
" ` ` ' / >"+nl+
" ` ` \\/> "+nl+
" ` ` __________>,^"+nl+
" ` \\\\\\\\-=-=-=-=-=-/{}"+nl+
"-~-~-~-~-~-~-~' `-~-~-~-~-~-~-~-~"+nl+
"~ejm97~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-",
" "+nl+
" "+nl+
" "+nl+
" ."+nl+
" ' _"+nl+
" ` . ---#^,/"+nl+
" ` ` / >"+nl+
" ` ` . \\/> "+nl+
" ` ` . __________>,^"+nl+
" ` ` ` \\-=-=-=-=-=-/{}"+nl+
"~-~-~-~-~-~-~-~\\\\\\\\.~-~-~-~-~-~-~-"+nl+
"-ejm97-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~",
" "+nl+
" "+nl+
" "+nl+
" "+nl+
" ` . _"+nl+
" `` ' ===-^,/"+nl+
" ` ` >"+nl+
" ` ' \\/> "+nl+
" ` . __________>,^"+nl+
" ` \\-=-=-=-=-=-/{}"+nl+
"-~-~-~-~-~-~-~-`-.-~-~-~-~-~-~-~-~-~"+nl+
"~ejm97~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-",
" "+nl+
" "+nl+
" "+nl+
" "+nl+
" . ` ' _"+nl+
" ` ` ===-^,/"+nl+
" . >"+nl+
" ` ' \\/> "+nl+
" . __________>,^"+nl+
" ` \\-=-=-=-=-=-/{}"+nl+
"~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-"+nl+
"-ejm97-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~",
" "+nl+
" "+nl+
" "+nl+
" "+nl+
" ` _"+nl+
" ` ===-^,/"+nl+
" ` ` ' >"+nl+
" ` \\/> "+nl+
" __________>,^"+nl+
" \\-=-=-=-=-=-/{я}"+nl+
"-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~"+nl+
"~ejm97~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-",
" "+nl+
" "+nl+
" "+nl+
" "+nl+
" ` ' _"+nl+
" ` ===-^,/"+nl+
" >"+nl+
" \\/> "+nl+
" __________>,^"+nl+
" \\-=-=-=-=-=-/{}"+nl+
"~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-"+nl+
"-ejm97-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~",
" "+nl+
" "+nl+
" "+nl+
" "+nl+
" _"+nl+
" ===%^,/"+nl+
" >"+nl+
" \\/> "+nl+
" __________>,^"+nl+
" \\-=-=-=-=-=-/{}"+nl+
"-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~"+nl+
"~ejm97~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-",
" "+nl+
" "+nl+
" "+nl+
" "+nl+
" \\"+nl+
" ---%^,/"+nl+
" / >"+nl+
" _/> "+nl+
" __________>,^"+nl+
" \\-=-=-=-=-=-/{}"+nl+
"~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-"+nl+
"-ejm97-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~",
" "+nl+
" "+nl+
" "+nl+
" "+nl+
" _"+nl+
" ---%^,/ "+nl+
" / >"+nl+
" _/> _"+nl+
" _________>,^_\\"+nl+
" \\-=-=-=-=-=-/{}"+nl+
"-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~"+nl+
"~ejm97~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-",
" "+nl+
" "+nl+
" "+nl+
" "+nl+
" "+nl+
" ===%^,"+nl+
" >"+nl+
" /> _"+nl+
" _______/_>,^_\\"+nl+
" \\-=-=-=-=-=-/{}"+nl+
"~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-"+nl+
"-ejm97-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~",
" "+nl+
" "+nl+
" "+nl+
" "+nl+
" "+nl+
" ===-^,"+nl+
" >"+nl+
" _/> _"+nl+
" _________>,^_\\"+nl+
" \\-=-=-=-=-=-/{}"+nl+
"-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~"+nl+
"~ejm97~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-",
" "+nl+
" "+nl+
" "+nl+
" "+nl+
" "+nl+
" ===%^,"+nl+
" >"+nl+
" \\/> _"+nl+
" _________>,^_\\"+nl+
" \\-=-=-=-=-=-/{}"+nl+
"~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-"+nl+
"-ejm97-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~",
" "+nl+
" "+nl+
" "+nl+
" "+nl+
" "+nl+
" ===-^,"+nl+
" >"+nl+
" \\/> _"+nl+
" _________>,^_\\"+nl+
" \\-=-=-=-=-=-/{}"+nl+
"-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~"+nl+
"~ejm97~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-",
" "+nl+
" "+nl+
" "+nl+
" "+nl+
" "+nl+
" ===%^,"+nl+
" >"+nl+
" \\/> _"+nl+
" _________>,^_\\"+nl+
" \\-=-=-=-=-=-/{}"+nl+
"~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-"+nl+
"-ejm97-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~",
" "+nl+
" "+nl+
" "+nl+
" "+nl+
" "+nl+
" ---%^,"+nl+
" Rats. / >"+nl+
" _/> _"+nl+
" _________>,^_\\"+nl+
" \\-=-=-=-=-=-/{}"+nl+
"-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~"+nl+
"~ejm97~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-",
" "+nl+
" "+nl+
" "+nl+
" "+nl+
" "+nl+
" ---%^,"+nl+
" Rats. / >"+nl+
" _/> _"+nl+
" _________>,^_\\"+nl+
" \\-=-=-=-=-=-/{}"+nl+
"~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-"+nl+
"-ejm97-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~",
" "+nl+
" "+nl+
" "+nl+
" "+nl+
" "+nl+
" ---%^,"+nl+
" Rats. / >"+nl+
" _/> _"+nl+
" _________>,^_\\"+nl+
" я \\-=-=-=-=-=-/{}"+nl+
"-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~"+nl+
"~ejm97~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-",
" "+nl+
" "+nl+
" "+nl+
" "+nl+
" "+nl+
" ---%^,"+nl+
" Rats. / >"+nl+
" _/> _"+nl+
" _________>,^_\\"+nl+
" \\-=-=-=-=-=-/{}"+nl+
"~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-"+nl+
"-ejm97-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~",
" "+nl+
" "+nl+
" "+nl+
" "+nl+
" "+nl+
" ---%^,"+nl+
" Rats. / >"+nl+
" _/> _"+nl+
" _________>,^_\\"+nl+
" \\-=-=-=-=-=-/{}"+nl+
"-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~"+nl+
"~ejm97~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-",
" "+nl+
" "+nl+
" "+nl+
" "+nl+
" "+nl+
" ===%^,"+nl+
" >"+nl+
" _/> _"+nl+
" _________>,^_\\"+nl+
" \\-=-=-=-=-=-/{}"+nl+
"~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-"+nl+
"-ejm97-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~",
" "+nl+
" "+nl+
" "+nl+
" "+nl+
" "+nl+
" ===-^,"+nl+
" >"+nl+
" _/> _"+nl+
" _________>,^_\\"+nl+
" \\-=-=-=-=-=-/{}"+nl+
"-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~"+nl+
"~ejm97~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-",
" "+nl+
" "+nl+
" "+nl+
" "+nl+
" "+nl+
" ===%^,"+nl+
" >"+nl+
" _/> _"+nl+
" _________>,^_\\"+nl+
" \\-=-=-=-=-=-/{}"+nl+
"~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-"+nl+
"-ejm97-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~",
" "+nl+
" "+nl+
" "+nl+
" "+nl+
" "+nl+
" ===%^,"+nl+
" >"+nl+
" _/> _"+nl+
" _________>,^_\\"+nl+
" \\-=-=-=-=-=-/{}"+nl+
"-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-я~"+nl+
"~ejm97~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-",
" "+nl+
" "+nl+
" "+nl+
" "+nl+
" "+nl+
" ---%^,"+nl+
" / >"+nl+
" /> _"+nl+
" _______/_>,^_\\"+nl+
" \\-=-=-=-=-=-/{}"+nl+
"~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-"+nl+
"-ejm97-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~",
" "+nl+
" "+nl+
" "+nl+
" "+nl+
" "+nl+
" ---%^,"+nl+
" I lost my fishing rod. / >"+nl+
" /> _"+nl+
" _______/_>,^_\\"+nl+
" \\-=-=-=-=-=-/{}"+nl+
"-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~"+nl+
"~ejm97~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-"], // "Fishing" taken from http://asciimator.net/kangaroo/fishing.html
];
for (var s = 0; s < spinners.length; ++s) {
var spinner = spinners[s];
var div = document.createElement('div');
var el = document.createElement('pre');
div.appendChild(el);
document.body.appendChild(div);
(function(spinner, el) {
var i = 0;
setInterval(function() {
el.innerHTML = spinner[i];
i = (i + 1) % spinner.length;
}, 300);
})(spinner, el);
}
pre {
font-family: monospace;
font-size: 1.5em;
font-weight: bold;
border: 1px solid #eee;
display: inline-block;
margin: .25em;
}
There's more # cli-spinners, courtesy of Sindre Sorhus.
You can nab the JSON for them here.
I JavaScriptified them here: JsBin
Balloons...
. o O # *
If you have more than one character worth of space, you can use animated ASCII art. For example, you can do a progress bar like:
[ ]
[== ]
[===== ]
[======== ]
or a "bouncing ball" progress indicator (that moves back and forth) like:
(-*--------) // moving -->
(-----*----) // moving -->
(---------*) // moving -->
(--------*-) // moving <--
(---*------) // moving <--
(*---------) // moving <--
Something more advanced like this loading animation might also work.
Edit:
There's also the "executive desk toy"
╔════╤╤╤╤════╗ ╔════╤╤╤╤════╗ ╔════╤╤╤╤════╗ ╔════╤╤╤╤════╗
║ │││ \ ║ ║ ││││ ║ ║ / │││ ║ ║ ││││ ║
║ │││ O ║ -> ║ ││││ ║ -> ║ O │││ ║ -> ║ ││││ ║
║ OOO ║ ║ OOOO ║ ║ OOO ║ ║ OOOO ║
And of course there's the ultimate example of animated ASCII art, if you had the time to implement something similar (it would take "spicing up a console application" to the extreme).
Edit: If your console supports color, you can also spice up an otherwise-boring standard spinner by cycling through colors as you spin. Start off with a red line, then slowly fade through the rainbow up to violet as you spin. This can look especially cool with the "bouncing ball" indicator above if you have the ball "paint" the bar a different color on every pass.
Definitely LOLLERSKATES!
/\O | _O | O
/\/ | //|_ | /_
/\ | | | |\
/ \ | /| | / |
LOL LOL | LLOL | LOLLOL
-----------+----------+-----------
Frame 0 | Frame 1 | Frame 2
There used to be a a DOS linker named blinker, by Blink Inc. It would display an animation similar to this while it was working:
(o)(o)
(-)(-)
(_)(_)
With the first frame displaying for about a second, and the other two animating briefly once a second or two, making the command line appear to blink its eyes. The effect was pretty cool, actually.
The linker even had options to blink one eye, and you could choose which eye would blink.
I've used a cycle of
Working.
Working..
Working...
Inspirational I know
If you know how far through the process you are I like the percentage bar. It looks nice, feels intuitive and is easy to implement:
| 0%
|| 5%
|||||| 25%
||||||||||||||||||||| 100%
fish is a Python module that animates an ASCII fish going back and forth, and who doesn't like the rare console fish?
>))'>
>))'>
>))'>
<'((<
<'((<
Try these
'+', 'x'
'v', '<', '^', '>'
All taken from:
http://llizard.cwahi.net/animals.html
Bats Flying!
/^v^\
/^v^\ /^v^\
/^v^\
/^v^\
Flap flap!
\^v^/
\^v^/ \^v^/
\^v^/
\^v^/
Wow wow An Archer!
/\
/__\_{)
|--<<)__\
\ / (
\/ )
/|
\ \
~ ~
/| \
/_|_{)/
---<< | | )
\ | (
\| )
/|
\ \
~ ~
\
/|{)/
---<< +-|-)
\| (
)
/|
\ \
~ ~
/\
/__\_{)
|--<<)__\
\ / (
\/ __)
\ |__
~ ~
/| \
/_|_{)/
---<< | | )
\ | (
\|__)
\ |__
~ ~
\
/|{)/
---<< +-|-)
\| (
__)
\ |__
~ ~
Super Cyclist
---------- __o
-------- _ \<,_
------- (*)/ (*)
Wheeeee!
Flying a Kite
/\
'\/
' +
' +
' +
' +
' +
' +
'
'
'
'
'
'
'
'
__ '
\o . '
\\/
/\
/ /
This fishing one is pretty hillarious as well
http://asciimator.net/kangaroo/fishing.html
In Javascript using one jQuery selectors:
var spins = [
"←↖↑↗→↘↓↙",
"▁▃▄▅▆▇█▇▆▅▄▃",
"▉▊▋▌▍▎▏▎▍▌▋▊▉",
"▖▘▝▗",
"┤┘┴└├┌┬┐",
"◢◣◤◥",
"◰ ◳ ◲ ◱",
"◴◷◶◵",
"◐◓◑◒",
"|/-\\"];
var spin = spins[0],
title$ = $('title'),
i=0;
setInterval(function() {
i = i==spin.length-1 ? 0 : ++i;
title$.text('('+ spin[i] +') Loading...');
},300);
I'm glad I'm not the only one crazy enough to waste time on this!
Here are my favourites (some using dos ascii codes):
classic: "/-\\|";
bouncing ball: ".oOo";
better bouncing ball: [46, 111, 79, 248, 79, 111]; // (.oO°Oo.)
[180, 217, 193, 192, 195, 218, 194, 191]; // ┤ ┘ ┴ └ ├ ┌ ┬ ┐
[185, 188, 202, 200, 204, 201, 203, 187]; // double piped version of that
[219, 220, 223]; // block colours
Makes a cute "rain" effect:
using System;
using System.Text;
using System.Threading;
namespace CSharpSandbox
{
class Program
{
static Random rnd = new Random();
static char[,] Step(char[,] matrix)
{
int width = matrix.GetUpperBound(0) + 1;
int height = matrix.GetUpperBound(1) + 1;
char[,] res = new char[width, height];
for (int h = 0; h < height; h++)
{
for (int w = 0; w < width; w++)
{
char c;
if (h == 0)
c = rnd.Next(2) == 0 ? ' ' : '*';
else
c = matrix[w, h - 1];
res[w, h] = c;
}
}
return res;
}
static string ToString(char[,] matrix)
{
int width = matrix.GetUpperBound(0) + 1;
int height = matrix.GetUpperBound(1) + 1;
StringBuilder sb = new StringBuilder();
for (int h = 0; h < height; h++)
{
for (int w = 0; w < width; w++)
{
sb.Append(matrix[w, h]);
}
sb.AppendLine();
}
return sb.ToString();
}
static Timer timer;
static void Spinner()
{
char[,] matrix = new char[10, 5];
timer = new Timer(_ =>
{
string s = ToString(matrix);
Console.SetCursorPosition(0, 0);
Console.Write(s);
matrix = Step(matrix);
},
null,
0,
200);
}
static void Main(string[] args)
{
Spinner();
Console.ReadLine();
}
}
}
In one application, I saw 1,2,3,4,5,6,7,8,9,0.
Courtesy of a co-worker of mine, here's a nifty implementation in C:
#define COW 2172
char* moo = "MO ";
void wrap() {
int i,j;
for(i=0;doSomething(i);i++)
j=COW-moo[i&3],fputs(&j,stderr);
}
From my analysis, it only works on a little-endian machine with at least 32-bit words and the ASCII character set. But it's rather diabolically clever.
I wrote one that cycled through the standard \ | / - but the left a _ and moved on to the next position. It was intended to look as though there were a series of spinners, each dropping to the floor before the next one started. The need for this was that my program was repeatedly trying something and waiting for a certain result. I wanted to represent each time it tried and also how many times it had tried without using up a lot of screen space (or count).
After I wrote it it looked a lot less cool than I thought it would, but it served its purpose.
I have seen
echo -e "\033[41;1m$1 \033[0m"
In bash to continually build a progress bar based on a block character.
Related
FIlter a value from stdout_lines of Ansible output below
I would like to FIlter value of Endpoint from stdout_lines of Ansible output below: "{", " \"DBCluster\": {", " \"MasterUsername\": \"mstrusr\", ", " \"ReaderEndpoint\": \"tstng4.cluster-ro-czzpyhxnqlzh.us-east-1.docdb.amazonaws.com\", ", " \"VpcSecurityGroups\": [", " {", " \"Status\": \"active\", ", " \"VpcSecurityGroupId\": \"sg-xxx5677\"", " }", " ], ", " \"HostedZoneId\": \"ZNKXH85TT8WVW\", ", " \"Status\": \"creating\", ", " \"MultiAZ\": false, ", " \"PreferredBackupWindow\": \"03:51-04:21\", ", " \"DBSubnetGroup\": \"subnet\", ", " \"BackupRetentionPeriod\": 1, ", " \"PreferredMaintenanceWindow\": \"mon:05:00-mon:05:30\", ", " \"Engine\": \"docdb\", ", " \"Endpoint\": \"tstng4.cluster-czzpyhxnqlzh.us-east-1.docdb.amazonaws.com\", ", " \"ClusterCreateTime\": \"2020-01-23T10:06:44.338Z\", ", " \"EngineVersion\": \"3.6.0\", ", " \"DeletionProtection\": true, ", " \"DBClusterIdentifier\": \"vce-docdb-tst4\", ", " \"DbClusterResourceId\": \"cluster-E3ICGSCJRPWDY7NRQTELXFCKTQ\", ", " \"DBClusterMembers\": [], ", " \"Port\": 27017, ", " \"StorageEncrypted\": false, ", " \"AssociatedRoles\": [], ", " \"DBClusterParameterGroup\": \"default.docdb3.6\", ", " \"AvailabilityZones\": [", " \"us-east-1a\", ", " \"us-east-1b\", ", " \"us-east-1c\"", " ], ", " \"DBClusterArn\": \"arn:aws:rds:us-east-1:570346948435:cluster:vce-docdb-tst4\"", " }", I am trying to use below filter to get value of Endpoint: stdout_lines.DBCluster.Endpoint
Your result is the json object which have to be piped through from_json filter. Simple test: - hosts: masters gather_facts: false tasks: - shell: /root/ansible/test.sh register: result - debug: msg: "{{ (result.stdout | from_json).DBCluster.Endpoint }}" Test data: #!/bin/bash echo '{' echo '"DBCluster": {' echo '"Endpoint": "value1"' echo '}, "key2": "value2"' echo '}'
case statements for different date columns
I'm facing issues while writing the below code in SQL developer: 'If Trim$(psFromDate) <> "" and NOT ISNULL(psFromDate) AND Trim$(psToDate) <> "" and NOT ISNULL(psToDate) Then select case ps_datetype CASE "CTA" wc = wc & " AND (trunc(sf_get_local (p_con.created_date,p_con.cdate_tz_code)) Between " wc = wc & " TO_DATE (" & "'" & sFromDate & "'" & ", 'DD/MM/YYYY') " wc = wc & " AND TO_DATE (" & "'" & sToDate & "'" & ", 'DD/MM/YYYY'))" 'CASE "ATA" CASE "VAD" wc = wc & " AND trunc(sf_get_local(route_s.orgn_vsl_arvl_date,route_s.orgn_vsl_arvl_date_tz_code)) Between " wc = wc & " TO_DATE (" & "'" & sFromDate & "'" & ", 'DD/MM/YYYY') " wc = wc & " AND TO_DATE (" & "'" & sToDate & "'" & ", 'DD/MM/YYYY')" CASE "ETA" wc = wc & " AND TRUNC(sf_get_local(route_s.arrival_date,route_s.arrival_date_tz_code)) Between " wc = wc & " TO_DATE (" & "'" & sFromDate & "'" & ", 'DD/MM/YYYY') " wc = wc & " AND TO_DATE (" & "'" & sToDate & "'" & ", 'DD/MM/YYYY')" END SELECT 'End If I tried the below code but no luck: Where (case when pstatustype='CTA' then (p_con.created_date Between to_date('&1','DD-MON-YYYY:HH24:MI:SS') AND to_date('&2','DD-MON-YYYY:HH24:MI:SS')) when pstatustype='VAD' then (route_s.orgn_vsl_arvl_date Between to_date('&1','DD-MON-YYYY:HH24:MI:SS') AND to_date('&2','DD-MON-YYYY:HH24:MI:SS')) when pstatustype='ETA' then (route_s.arrival_date Between to_date('&1','DD-MON-YYYY:HH24:MI:SS') AND to_date('&2','DD-MON-YYYY:HH24:MI:SS')) else NULL end) getting an error missing parenthesis. In then it is not taking BETWEEN operator. Please help, how i can write this code in SQL developer. Regards, fuko
You can't put other conditions inside the case expression clauses. You could either switch to simpler Boolean logic: Where (pstatustype='CTA' AND p_con.created_date Between to_date('&1','DD-MON-YYYY:HH24:MI:SS') AND to_date('&2','DD-MON-YYYY:HH24:MI:SS')) OR (pstatustype='VAD' AND route_s.orgn_vsl_arvl_date Between to_date('&1','DD-MON-YYYY:HH24:MI:SS') AND to_date('&2','DD-MON-YYYY:HH24:MI:SS')) OR (pstatustype='ETA' AND (route_s.arrival_date Between to_date('&1','DD-MON-YYYY:HH24:MI:SS') AND to_date('&2','DD-MON-YYYY:HH24:MI:SS')) or just pick the relevant date column in the case expression and compare that with a single date range: Where case when pstatustype='CTA' then p_con.created_date when pstatustype='VAD' then route_s.orgn_vsl_arvl_date when pstatustype='ETA' then route_s.arrival_date else null -- default anyway end Between to_date('&1','DD-MON-YYYY:HH24:MI:SS') AND to_date('&2','DD-MON-YYYY:HH24:MI:SS')
Creating map function in Red language
How can I create map, a higher order function, in Red language. It should take a block and a function as arguments and apply the sent function to each member of block. I tried following code: Red [] mapfn: function[blk sfn][ outblk: copy [] foreach i blk[ append outblk (sfn i) ] outblk ] ; to test: myblk: [" this " " is " " a " " line " "for" " testing " " only "] probe mapfn myblk 'reverse probe mapfn myblk 'trim But it is not working - it simply sends back the original block without changing it or giving any error message. How can this be corrected?
In Rebol you have the mezzanine function apply >> help apply USAGE: APPLY func block /only DESCRIPTION: Apply a function to a reduced block of arguments. APPLY is a function value. ARGUMENTS: func -- Function value to apply (Type: any-function) block -- Block of args, reduced first (unless /only) (Type: block) REFINEMENTS: /only -- Use arg values as-is, do not reduce the block (SPECIAL ATTRIBUTES) throw See source apply. As long as Red has no native apply you can write your own mapping function e.g mapfn: function[blk sfn][ outblk: copy [] foreach i blk[ append outblk sfn copy i ] outblk ] Get the function with :functionname >> myblk: [" this " " is " " a " " line " "for" " testing " " only "] == [" this " " is " " a " " line " "for" " testing " " only "] >> probe mapfn myblk :reverse [" siht " " si " " a " " enil " "rof" " gnitset " " ylno "] == [" siht " " si " " a " " enil " "rof" " gnitset " " ylno "] >> probe mapfn myblk :trim ["this" "is" "a" "line" "for" "testing" "only"] == ["this" "is" "a" "line" "for" "testing" "only"] >> An alternative and better way as you can not copy all datatypes is e.g. mapfn: function[blk sfn][ collect [ foreach i blk[ keep sfn i ] ] ] and call the function this way if no do not want to modify the original mapfn newblk: copy/deep myblk :reverse
How to split string by comma except the comma in double quote string
I want to split the following data by comma except the comma in double quote string "(CONTRACTS OF 5,000 BUSHELS)" How to do it ? raw_str.split doesn't work raw_str = '"WHEAT-SRW " ,150106 , CBT ,00 ,001 , 31.5, 26.4, "(CONTRACTS OF 5,000 BUSHELS)"' Actually I want to parse the file from "http://www.cftc.gov/dea/newcot/f_disagg.txt" html = Curl.get("http://www.cftc.gov/dea/newcot/f_disagg.txt") html.body_str.split ~~~~
Why reïnvent the wheel ? Your text is CSV, so use the CSV gem like this require 'csv' CSV.foreach("f_disagg.txt", {:headers=>false, :col_sep => ",", force_quotes: false, :quote_char => "\x00"}) do |row| p row end ["\"WHEAT-SRW - CHICAGO BOARD OF TRADE\" ", "150106 ", "2015-01-06", "001602 ", "CBT ", "00 ", "001 ", " 375872", " 32141", " 138392", " 111530", " 5662", " 14877", " 92842", " 75279", " 34611", " 34276", " 44861", " 22692", " 342969", " 336374", " 32903", " 39498", " 260179", " 19786", " 85222", " 93057", " 6641", " 1023", " 67360", " 78720", " 16703", " 36845", " 42816", " 4110", " 238884", " 235235", " 21295", " 24944", " 115693", " 12355", " 53170", " 21065", " 1613", " 11262", " 34424", " 5501", " 8966", " 5915", " 10529", " 10098", " 104085", " 101139", " 11608", " 14554", " 3895", " -1034", " -7666", " -763", " 225", " 312", " -4547", " 2110", " 6077", " -334", " -435", " 1750", " 1461", " 2373", " 2434", " 1522", " 100.0", " 8.6", " 36.8", " 29.7", " 1.5", " 4.0", " 24.7", " 20.0", " 9.2", " 9.1", " 11.9", " 6.0", " 91.2", " 89.5", " 8.8", " 10.5", " 100.0", " 7.6", " 32.8", " 35.8", " 2.6", " 0.4", " 25.9", " 30.3", " 6.4", " 14.2", " 16.5", " 1.6", " 91.8", " 90.4", " 8.2", " 9.6", " 100.0", " 10.7", " 46.0", " 18.2", " 1.4", " 9.7", " 29.8", " 4.8", " 7.7", " 5.1", " 9.1", " 8.7", " 90.0", " 87.4", " 10.0", " 12.6", " 353", " 63", " 84", " 21", " 5", " 16", " 69", " 35", " 43", " 45", " 66", " 67", " 269", " 261", " 340", " 45", " 79", " 21", " 5", " .", " 66", " 33", " 31", " 54", " 63", " 38", " 215", " 225", " 222", " 37", " 68", " 17", " 6", " 14", " 33", " 13", " 12", " 23", " 46", " 29", " 144", " 161", " 16.2", " 12.2", " 26.0", " 21.6", " 14.6", " 10.9", " 24.0", " 18.5", " 18.4", " 14.9", " 30.4", " 25.7", " 18.2", " 14.9", " 29.9", " 25.6", " 23.6", " 19.4", " 37.6", " 32.5", " 21.7", " 17.7", " 31.5", " 26.4", "\"(CONTRACTS OF 5", "000 BUSHELS)\" ", "\"001602\" ", "\"CBT\" ", "\"001\" ", "\"A10\" ", "\"FutOnly\""], etc EDIT: here a version that deals with the comma between parentheses, if a ) is found then the field is joined with the precious and the field it self deleted CSV.foreach("f_disagg.txt", {:headers=>false, :col_sep => ",", force_quotes: false, :quote_char => "\x00"}) do |row| row.each_with_index do |val, index| if val[')'] row[index-1] = "#{row[index-1]},#{val}" row.delete_at(index) val = '' end val end p row end
You can accomplish this using regex and "negative lookahead" and "negative lookbehind"[0]: raw_str = '"WHEAT-SRW " ,150106 , CBT ,00 ,001 , 31.5, 26.4, "(CONTRACTS OF 5,000 BUSHELS)"' raw_str.split(/(,)(?<!")(!?=")/) ["\"WHEAT-SRW \" ,150106 ,2015-01-06,001602 \n ,CBT ,00 ,001 , 375872, 32141, 14.9, \n37.6, 32.5, 21.7, 17.7, \n31.5, 26.4, \"(CONTRACTS OF 5,000 BUSHELS)\""] You're saying: "put the comma in a capture group, only if it wasn't preceded by a double quote and if it's not followed by a double quote." [0] http://ruby-doc.org/core-2.2.0/Regexp.html#class-Regexp-label-Anchors
Load Knockout observableArray with server Json populate only one element
here I am developing an application that retrieve data in a server via jquery ajax with then I do the Databindings with knockout The data json well pass to my scripts the only the problem is that in my html table only one record appears here my json as given by the server: Json returned by the server: { "Id": "4 ", " key_0 ": " 4 ", " Nom_Agent ": " Grace ", " key_1 ": " Grace ", " PNom_Agent ": " Malulu ", " key_2 ": " Malulu " " Sexe_Agent ", " M ", " key_3 ", " M ", " Adresse_Agent ", " 2 ", " key_4 ", " 2 ", " Telephone_Agent ": " 243 900 100 115 ", " key_5 ": " 243 900 100 115 " " Libelle_Role ": " Cashier ", " key_6 ": " Cashier ", " Email_Agent ": " gracemalulu#gmail.com ", " key_7 ": " gracemalulu#gmail.com ", " Nom_Agence ": " KIN 02 " " key_8 ": " 02 KIN ", " Libelle_Caisse ": "", " key_9 ": "", " Id_Agence ", " 2", " key_10 ", " 2", " role_id ", " 2", " key_11 " " 2", " Id_Caisse ": " ", " key_12 ": "", "Password ": " 7f59e02e7deaa6a33004b25a86024dee ", " key_13 ": " 7f59e02e7deaa6a33004b25a86024dee ", " Username": " gmalulu ", " key_14 ": " gmalulu " " Active ": " 1", " key_15 ": " 1 " }, { " Id", " 2", " key_0 ", " 2", " Nom_Agent " " Vasco ", " key_1 " " Vasco ", " PNom_Agent " " Kabangu " " key_2 " " Kabangu ", " Sexe_Agent ", " M ", " key_3 ", " M ", " Adresse_Agent " " iSC ", " key_4 " " iSC ", " Telephone_Agent ": " 243 ", " key_5 ": " 243 ", " Libelle_Role ": " Agency head ", " key_6 ": " Agency head ", " Email_Agent ": " vkabungu # ", " key_7 ": " vkabungu # ", " Nom_Agence ": " KIN 02 ", " key_8 ": " KIN 02 ", " Libelle_Caisse ": " ", " key_9 ": " ", " Id_Agence ", " 2 ", " key_10 ", " 2 ", " role_id ", " 3 ", " key_11 ", " 3 ", " Id_Caisse ": " ", " key_12 ": " ", " Password ": " 325a2cc052914ceeb8c19016c091d2ac ", " key_13 ": " 325a2cc052914ceeb8c19016c091d2ac ", " Username ": " vkabungu ", " key_14 ": " vkabungu ", " Active ": " 1 ", " key_15 " " 1 " }, { " Id", " 1", " key_0 ": " 1", " Nom_Agent " " Lepeya " " key_1 " " Lepeya " " PNom_Agent " " Otoko " " key_2 " " Otoko ", " Sexe_Agent ", " M ", " key_3 ", " M ", " Adresse_Agent " " lol122 Mombele " " key_4 " " lol122 Mombele " " Telephone_Agent ": " 213 ", " key_5 ": " 213 " " Libelle_Role ": " Cashier ", " key_6 ": " Cashier ", " Email_Agent ": " lepeyaherve#agb.cd ", " key_7 ": " lepeyaherve#agb.cd ", " Nom_Agence ": " KIN 02 " " key_8 ": " 02 KIN ", " Libelle_Caisse " " Case 01 ", " key_9 " " Case 01 ", " Id_Agence ", " 2", " key_10 ", " 2", " role_id " " 2" " key_11 ": " 2", " Id_Caisse ": " 2", " key_12 ": " 2", " Password ": " 325a2cc052914ceeb8c19016c091d2ac ", " key_13 ": " 325a2cc052914ceeb8c19016c091d2ac ", " Username": " lherve " " key_14 ": " lherve ", " Active ": " 0 ", " key_15 ": " 0 " }] the script knockout: <script type="text/javascript"> function Agent(data) { this.id=data.id; this.Nom_Agent=data.Nom_Agent; this.PNom_Agent=data.PNom_Agent; this.Sexe_Agent=data.Sexe_Agent; this.Adresse_Agent=data.Adresse_Agent; this.Telephone_Agent=data.Telephone_Agent; this.Libelle_Role=data.Libelle_Role; this.Email_Agent=data.Email_Agent; this.Nom_Agence=data.Nom_Agence; this.Username=data.Username; this.Id_Role=data.Id_Role; this.Id_Caisse=data.Id_Caisse; this.Date_Affectation=data.Date_Affectation; this.Libelle_Caisse=data.Libelle_Caisse; this.Id_Lieu=data.Id_Lieu; this.Active=ko.observable(data.Active) } function AgentListViewModel() { // Data var self = this; self.agents= ko.observableArray([]); $.ajax("/agence/allagent", { contentType: "application/json", success: function(result) { var mappedAgents = $.map( result, function(item) { return new Agent(item) ; }); self.agents(mappedAgents); }); } ko.applyBindings(new AgentListViewModel()); </script> please help me
you can set the observable array using the knockout mapping plugin AgentListViewModel function ( ) { var self = this; self.agents ko.observableArray = ( [ ] ) ; $.ajax ("/branch/allagent" { contentType : "application/json " success : function ( result) { ko.mapping.fromJS(result, {}, self.agents) }; } }); } I set up a fiddle with an example of how you can use it. Example