Load Knockout observableArray with server Json populate only one element - ajax

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

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 '}'

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

rspec giving undefined method

RSpec noob needs help. My brain is mush right now...I'm trying to create a basic "I exist and I return a value" set of test for this method in my code...
def attempt_win(board)
#ai_winmoves.each do |k, v| # go through each win move in the ai_winmoves array located above.
ai_keys = v.select{ |k, v| v == "O"}.keys # grab all computer player's Os from the value hash
intersection = ai_keys & #keys_with_o # get common elements between two arrays..note: keys_with_o = all current O's on game board
if intersection.length >=2 # when two intersections exist it means two O's are on the board
#answers_array << k # add to answers array per iteration
#answers_array.each do |key|
# answer = #anskey[#thing.last].to_sym
puts "which moves can ai win with?"
puts #anskey[key]
answer = #anskey[key].to_sym
puts "attempt win"
puts answer
if board.grid[answer] == " " #if win move space is empty take it
#move = answer
else #check for a block move
# attempt_block # handled at line 162
end
end
end
end # END #ai_winmoves.each do |k,v|
end
Here is my test code...
describe 'attempt_win' do
before (:each) do
#board.grid[:b2] == "X"
end
xit 'computer looks for any possible win move'
it 'computer returns a value' do
#player_computer.attempt_win(#board).should_not be(nil)
end
end
here is the rspec failure I'm getting...
1) Player class attempt_win computer returns a value
Failure/Error: #player_computer.attempt_win(#board).should_not be(nil)
NoMethodError:
undefined method `each' for nil:NilClass
# ./lib/player.rb:171:in `attempt_win'
# ./spec/player_spec.rb:47:in `block (3 levels) in <top (required)>'
THAT'S IT BUT.....
IF YOU WANT TO SEE THE ENTIRE CLASS FILE player.rb and it's test file player_spec.rb LOOK BELOW...
# TODO - send error output if move already taken
# TODO - better WIN detection
class Player
attr_reader :boardpiece # i exist so game.rb can read me
def initialize(letter)
#boardpiece = letter
end
def move_human(game, board)
#game_two = game
puts "human move..."
human_move = gets.chomp
human_symbol = human_move.to_sym
# look for move as key in board.grid
if board.grid.has_key?(human_symbol)
if board.grid[human_symbol] == " "
#puts "bingo"
#move = human_symbol
else
puts "spot taken...try again"
move_human(#game_two, board)
end
else
puts "invalid move...try again"
move_human(#game_two, board)
end
end
def move_computer(game, board)
# ai should do three things
# attempt win
# block human
# random move
puts "computer move..."
# all possible third moves as 'O' (computer)
#human_winmoves = {
:wm01 => {:a1=>"X", :a2=>" ", :a3=>" ", :b1=>" ", :b2=>"X", :b3=>" ", :c1=>" ", :c2=>" ", :c3=>" "},
:wm02 => {:a1=>" ", :a2=>"X", :a3=>" ", :b1=>" ", :b2=>"X", :b3=>" ", :c1=>" ", :c2=>" ", :c3=>" "},
:wm03 => {:a1=>" ", :a2=>" ", :a3=>"X", :b1=>" ", :b2=>"X", :b3=>" ", :c1=>" ", :c2=>" ", :c3=>" "},
:wm04 => {:a1=>" ", :a2=>" ", :a3=>" ", :b1=>"X", :b2=>"X", :b3=>" ", :c1=>" ", :c2=>" ", :c3=>" "},
:wm05 => {:a1=>" ", :a2=>" ", :a3=>" ", :b1=>" ", :b2=>"X", :b3=>"X", :c1=>" ", :c2=>" ", :c3=>" "},
:wm06 => {:a1=>" ", :a2=>" ", :a3=>" ", :b1=>" ", :b2=>"X", :b3=>" ", :c1=>"X", :c2=>" ", :c3=>" "},
:wm07 => {:a1=>" ", :a2=>" ", :a3=>" ", :b1=>" ", :b2=>"X", :b3=>" ", :c1=>" ", :c2=>"X", :c3=>" "},
:wm08 => {:a1=>" ", :a2=>" ", :a3=>" ", :b1=>" ", :b2=>"X", :b3=>" ", :c1=>" ", :c2=>" ", :c3=>"X"},
#check those corners
:wm09 => {:a1=>"X", :a2=>"X", :a3=>" ", :b1=>" ", :b2=>" ", :b3=>" ", :c1=>" ", :c2=>" ", :c3=>" "},
:wm10 => {:a1=>"X", :a2=>" ", :a3=>" ", :b1=>"X", :b2=>" ", :b3=>" ", :c1=>" ", :c2=>" ", :c3=>" "},
:wm11 => {:a1=>" ", :a2=>"X", :a3=>"X", :b1=>" ", :b2=>" ", :b3=>" ", :c1=>" ", :c2=>" ", :c3=>" "},
:wm12 => {:a1=>" ", :a2=>" ", :a3=>"X", :b1=>" ", :b2=>" ", :b3=>"X", :c1=>" ", :c2=>" ", :c3=>" "},
:wm13 => {:a1=>" ", :a2=>" ", :a3=>" ", :b1=>" ", :b2=>" ", :b3=>"X", :c1=>" ", :c2=>" ", :c3=>"X"},
:wm14 => {:a1=>" ", :a2=>" ", :a3=>" ", :b1=>" ", :b2=>" ", :b3=>" ", :c1=>" ", :c2=>"X", :c3=>"X"},
:wm15 => {:a1=>" ", :a2=>" ", :a3=>" ", :b1=>" ", :b2=>" ", :b3=>" ", :c1=>"X", :c2=>"X", :c3=>" "},
:wm16 => {:a1=>" ", :a2=>" ", :a3=>" ", :b1=>"X", :b2=>" ", :b3=>" ", :c1=>"X", :c2=>" ", :c3=>" "},
#check opposites
:wm17 => {:a1=>"X", :a2=>" ", :a3=>" ", :b1=>" ", :b2=>" ", :b3=>" ", :c1=>"X", :c2=>" ", :c3=>" "},
:wm18 => {:a1=>" ", :a2=>"X", :a3=>" ", :b1=>" ", :b2=>" ", :b3=>" ", :c1=>" ", :c2=>"X", :c3=>" "},
:wm19 => {:a1=>" ", :a2=>" ", :a3=>"X", :b1=>" ", :b2=>" ", :b3=>" ", :c1=>" ", :c2=>" ", :c3=>"X"},
:wm20 => {:a1=>"X", :a2=>" ", :a3=>"X", :b1=>" ", :b2=>" ", :b3=>" ", :c1=>" ", :c2=>" ", :c3=>" "},
:wm21 => {:a1=>" ", :a2=>" ", :a3=>" ", :b1=>"X", :b2=>" ", :b3=>"X", :c1=>" ", :c2=>" ", :c3=>" "},
:wm22 => {:a1=>"X", :a2=>" ", :a3=>" ", :b1=>" ", :b2=>" ", :b3=>" ", :c1=>" ", :c2=>" ", :c3=>"X"},
:wm23 => {:a1=>" ", :a2=>" ", :a3=>" ", :b1=>" ", :b2=>" ", :b3=>" ", :c1=>"X", :c2=>" ", :c3=>"X"},
:wm24 => {:a1=>" ", :a2=>" ", :a3=>"X", :b1=>" ", :b2=>" ", :b3=>" ", :c1=>"X", :c2=>" ", :c3=>" "},
#check crazy
:wm25 => {:a1=>" ", :a2=>"X", :a3=>" ", :b1=>" ", :b2=>" ", :b3=>" ", :c1=>"X", :c2=>" ", :c3=>" "},
:wm26 => {:a1=>" ", :a2=>"X", :a3=>" ", :b1=>"X", :b2=>" ", :b3=>" ", :c1=>" ", :c2=>" ", :c3=>" "},
:wm27 => {:a1=>" ", :a2=>"X", :a3=>" ", :b1=>" ", :b2=>" ", :b3=>" ", :c1=>" ", :c2=>" ", :c3=>"X"},
:wm28 => {:a1=>" ", :a2=>"X", :a3=>" ", :b1=>" ", :b2=>" ", :b3=>"X", :c1=>" ", :c2=>" ", :c3=>" "},
:wm29 => {:a1=>"X", :a2=>" ", :a3=>" ", :b1=>" ", :b2=>" ", :b3=>" ", :c1=>" ", :c2=>"X", :c3=>" "},
:wm30 => {:a1=>" ", :a2=>" ", :a3=>" ", :b1=>"X", :b2=>" ", :b3=>" ", :c1=>" ", :c2=>"X", :c3=>" "},
:wm31 => {:a1=>" ", :a2=>" ", :a3=>"X", :b1=>" ", :b2=>" ", :b3=>" ", :c1=>" ", :c2=>"X", :c3=>" "},
:wm32 => {:a1=>" ", :a2=>" ", :a3=>" ", :b1=>" ", :b2=>" ", :b3=>"X", :c1=>" ", :c2=>"X", :c3=>" "},
:wm33 => {:a1=>" ", :a2=>"X", :a3=>" ", :b1=>"X", :b2=>" ", :b3=>" ", :c1=>" ", :c2=>" ", :c3=>" "},
:wm34 => {:a1=>" ", :a2=>" ", :a3=>"X", :b1=>"X", :b2=>" ", :b3=>" ", :c1=>" ", :c2=>" ", :c3=>" "},
:wm35 => {:a1=>" ", :a2=>" ", :a3=>" ", :b1=>"X", :b2=>" ", :b3=>" ", :c1=>" ", :c2=>"X", :c3=>" "},
:wm36 => {:a1=>" ", :a2=>" ", :a3=>" ", :b1=>"X", :b2=>" ", :b3=>" ", :c1=>" ", :c2=>" ", :c3=>"X"},
:wm37 => {:a1=>"X", :a2=>" ", :a3=>" ", :b1=>" ", :b2=>" ", :b3=>"X", :c1=>" ", :c2=>" ", :c3=>" "},
:wm38 => {:a1=>" ", :a2=>"X", :a3=>" ", :b1=>" ", :b2=>" ", :b3=>"X", :c1=>" ", :c2=>" ", :c3=>" "},
:wm39 => {:a1=>" ", :a2=>" ", :a3=>" ", :b1=>" ", :b2=>" ", :b3=>"X", :c1=>"X", :c2=>" ", :c3=>" "},
:wm40 => {:a1=>" ", :a2=>" ", :a3=>" ", :b1=>" ", :b2=>" ", :b3=>"X", :c1=>" ", :c2=>"X", :c3=>" "}
}
#ai_winmoves = {
:wm01 => {:a1=>"O", :a2=>" ", :a3=>" ", :b1=>" ", :b2=>"O", :b3=>" ", :c1=>" ", :c2=>" ", :c3=>" "},
:wm02 => {:a1=>" ", :a2=>"O", :a3=>" ", :b1=>" ", :b2=>"O", :b3=>" ", :c1=>" ", :c2=>" ", :c3=>" "},
:wm03 => {:a1=>" ", :a2=>" ", :a3=>"O", :b1=>" ", :b2=>"O", :b3=>" ", :c1=>" ", :c2=>" ", :c3=>" "},
:wm04 => {:a1=>" ", :a2=>" ", :a3=>" ", :b1=>"O", :b2=>"O", :b3=>" ", :c1=>" ", :c2=>" ", :c3=>" "},
:wm05 => {:a1=>" ", :a2=>" ", :a3=>" ", :b1=>" ", :b2=>"O", :b3=>"O", :c1=>" ", :c2=>" ", :c3=>" "},
:wm06 => {:a1=>" ", :a2=>" ", :a3=>" ", :b1=>" ", :b2=>"O", :b3=>" ", :c1=>"O", :c2=>" ", :c3=>" "},
:wm07 => {:a1=>" ", :a2=>" ", :a3=>" ", :b1=>" ", :b2=>"O", :b3=>" ", :c1=>" ", :c2=>"O", :c3=>" "},
:wm08 => {:a1=>" ", :a2=>" ", :a3=>" ", :b1=>" ", :b2=>"O", :b3=>" ", :c1=>" ", :c2=>" ", :c3=>"O"},
#check those corners
:wm09 => {:a1=>"O", :a2=>"O", :a3=>" ", :b1=>" ", :b2=>" ", :b3=>" ", :c1=>" ", :c2=>" ", :c3=>" "},
:wm10 => {:a1=>"O", :a2=>" ", :a3=>" ", :b1=>"O", :b2=>" ", :b3=>" ", :c1=>" ", :c2=>" ", :c3=>" "},
:wm11 => {:a1=>" ", :a2=>"O", :a3=>"O", :b1=>" ", :b2=>" ", :b3=>" ", :c1=>" ", :c2=>" ", :c3=>" "},
:wm12 => {:a1=>" ", :a2=>" ", :a3=>"O", :b1=>" ", :b2=>" ", :b3=>"O", :c1=>" ", :c2=>" ", :c3=>" "},
:wm13 => {:a1=>" ", :a2=>" ", :a3=>" ", :b1=>" ", :b2=>" ", :b3=>"O", :c1=>" ", :c2=>" ", :c3=>"O"},
:wm14 => {:a1=>" ", :a2=>" ", :a3=>" ", :b1=>" ", :b2=>" ", :b3=>" ", :c1=>" ", :c2=>"O", :c3=>"O"},
:wm15 => {:a1=>" ", :a2=>" ", :a3=>" ", :b1=>" ", :b2=>" ", :b3=>" ", :c1=>"O", :c2=>"O", :c3=>" "},
:wm16 => {:a1=>" ", :a2=>" ", :a3=>" ", :b1=>"O", :b2=>" ", :b3=>" ", :c1=>"O", :c2=>" ", :c3=>" "},
#check opposites
:wm17 => {:a1=>"O", :a2=>" ", :a3=>" ", :b1=>" ", :b2=>" ", :b3=>" ", :c1=>"O", :c2=>" ", :c3=>" "},
:wm18 => {:a1=>" ", :a2=>"O", :a3=>" ", :b1=>" ", :b2=>" ", :b3=>" ", :c1=>" ", :c2=>"O", :c3=>" "},
:wm19 => {:a1=>" ", :a2=>" ", :a3=>"O", :b1=>" ", :b2=>" ", :b3=>" ", :c1=>" ", :c2=>" ", :c3=>"O"},
:wm20 => {:a1=>"O", :a2=>" ", :a3=>"O", :b1=>" ", :b2=>" ", :b3=>" ", :c1=>" ", :c2=>" ", :c3=>" "},
:wm21 => {:a1=>" ", :a2=>" ", :a3=>" ", :b1=>"O", :b2=>" ", :b3=>"O", :c1=>" ", :c2=>" ", :c3=>" "},
:wm22 => {:a1=>"O", :a2=>" ", :a3=>" ", :b1=>" ", :b2=>" ", :b3=>" ", :c1=>" ", :c2=>" ", :c3=>"O"},
:wm23 => {:a1=>" ", :a2=>" ", :a3=>" ", :b1=>" ", :b2=>" ", :b3=>" ", :c1=>"O", :c2=>" ", :c3=>"O"},
:wm24 => {:a1=>" ", :a2=>" ", :a3=>"O", :b1=>" ", :b2=>" ", :b3=>" ", :c1=>"O", :c2=>" ", :c3=>" "},
#check crazy
:wm25 => {:a1=>" ", :a2=>"O", :a3=>" ", :b1=>" ", :b2=>" ", :b3=>" ", :c1=>"O", :c2=>" ", :c3=>" "},
:wm26 => {:a1=>" ", :a2=>"O", :a3=>" ", :b1=>"O", :b2=>" ", :b3=>" ", :c1=>" ", :c2=>" ", :c3=>" "},
:wm27 => {:a1=>" ", :a2=>"O", :a3=>" ", :b1=>" ", :b2=>" ", :b3=>" ", :c1=>" ", :c2=>" ", :c3=>"O"},
:wm28 => {:a1=>" ", :a2=>"O", :a3=>" ", :b1=>" ", :b2=>" ", :b3=>"O", :c1=>" ", :c2=>" ", :c3=>" "},
:wm29 => {:a1=>"O", :a2=>" ", :a3=>" ", :b1=>" ", :b2=>" ", :b3=>" ", :c1=>" ", :c2=>"O", :c3=>" "},
:wm30 => {:a1=>" ", :a2=>" ", :a3=>" ", :b1=>"O", :b2=>" ", :b3=>" ", :c1=>" ", :c2=>"O", :c3=>" "},
:wm31 => {:a1=>" ", :a2=>" ", :a3=>"O", :b1=>" ", :b2=>" ", :b3=>" ", :c1=>" ", :c2=>"O", :c3=>" "},
:wm32 => {:a1=>" ", :a2=>" ", :a3=>" ", :b1=>" ", :b2=>" ", :b3=>"O", :c1=>" ", :c2=>"O", :c3=>" "},
:wm33 => {:a1=>" ", :a2=>"O", :a3=>" ", :b1=>"O", :b2=>" ", :b3=>" ", :c1=>" ", :c2=>" ", :c3=>" "},
:wm34 => {:a1=>" ", :a2=>" ", :a3=>"O", :b1=>"O", :b2=>" ", :b3=>" ", :c1=>" ", :c2=>" ", :c3=>" "},
:wm35 => {:a1=>" ", :a2=>" ", :a3=>" ", :b1=>"O", :b2=>" ", :b3=>" ", :c1=>" ", :c2=>"O", :c3=>" "},
:wm36 => {:a1=>" ", :a2=>" ", :a3=>" ", :b1=>"O", :b2=>" ", :b3=>" ", :c1=>" ", :c2=>" ", :c3=>"O"},
:wm37 => {:a1=>"O", :a2=>" ", :a3=>" ", :b1=>" ", :b2=>" ", :b3=>"O", :c1=>" ", :c2=>" ", :c3=>" "},
:wm38 => {:a1=>" ", :a2=>"O", :a3=>" ", :b1=>" ", :b2=>" ", :b3=>"O", :c1=>" ", :c2=>" ", :c3=>" "},
:wm39 => {:a1=>" ", :a2=>" ", :a3=>" ", :b1=>" ", :b2=>" ", :b3=>"O", :c1=>"O", :c2=>" ", :c3=>" "},
:wm40 => {:a1=>" ", :a2=>" ", :a3=>" ", :b1=>" ", :b2=>" ", :b3=>"O", :c1=>" ", :c2=>"O", :c3=>" "}
}
# match current answers located in #thegrid with possible #anskey array, iterate for each item
#anskey={
:wm01=>"c3",:wm02=>"c2",:wm03=>"c1",:wm04=>"b3",:wm05=>"b1",:wm06=>"a3",:wm07=>"a2",:wm08=>"a1",
:wm09=>"a3",:wm10=>"c1",:wm11=>"a1",:wm12=>"c3",:wm13=>"c3",:wm14=>"c1",:wm15=>"c3",:wm16=>"a1",
:wm17=>"b1",:wm18=>"b2",:wm19=>"b3",:wm20=>"a2",:wm21=>"b2",:wm22=>"b2",:wm23=>"c2",:wm24=>"b2",
:wm25=>"a1",:wm26=>"a1",:wm27=>"a3",:wm28=>"a3",:wm29=>"c1",:wm30=>"c1",:wm31=>"c3",:wm32=>"c3",
:wm33=>"a1",:wm34=>"a1",:wm35=>"c1",:wm36=>"c1",:wm37=>"a3",:wm38=>"a3",:wm39=>"c3",:wm40=>"c3"
}
#
# scan board for available move locations
#keys_with_o = board.grid.select{ |k, v| v == "O" }.keys # find Os on the board
#keys_with_x = board.grid.select{ |k, v| v == "X" }.keys # find Xs on the board
#answers_array = [] # initialize answers array
if board.grid[:b2] == " " #AND center spot is empty
ai_spot = "b2"
# puts "ai takes center "+ai_spot
#move = ai_spot.to_sym #must return this answer as a symbol
else
# TODO - Ai attempts win
i = 0
until i == 4
attempt_win(board) #run 3x then run attempt_block
i = i+1 # add 1 to i
if i == 4
puts "running attempt_block..."
attempt_block(board)
end
end
end
return #move # had this guy in the wrong place
end
def attempt_win(board)
#ai_winmoves.each do |k, v| # go through each win move in the ai_winmoves array above.
ai_keys = v.select{ |k, v| v == "O"}.keys # grab all computer player's Os from the value hash
intersection = ai_keys & #keys_with_o # get common elements between two arrays..note: keys_with_o = all current O's on game board
if intersection.length >=2 # when two intersections exist it means two O's are on the board
#answers_array << k # add to answers array per iteration
#answers_array.each do |key|
# answer = #anskey[#thing.last].to_sym
puts "which moves can ai win with?"
puts #anskey[key]
answer = #anskey[key].to_sym
puts "attempt win"
puts answer
if board.grid[answer] == " " #if win move space is empty take it
#move = answer
else #check for a block move
# attempt_block # handled at line 162
end
end
end
end # END #ai_winmoves.each do |k,v|
end
def attempt_block(board)
puts "attempt block method - hi"
# thing = [] # initialize thing array
#human_winmoves.each do |k,v| # for test - go threw each win moves.
# get common elements between two arrays..recall from above that v contains a hash
human_keys = v.select{ |k, v| v == "X"}.keys
# which moves can I take to block human
intersection = human_keys & #keys_with_x
if intersection.length >= 2
puts "intersection"
puts intersection
#answers_array << k # adds a key per iteration
puts "#answers_array << k"
puts #anskey[k]
#answers_array.each do |key|
puts "which moves can ai block with?"
puts #anskey[key]
answer = #anskey[key].to_sym
puts "attempt block"
puts answer
# if board.spot_taken?(answer)
if board.grid[answer] != " " # spot taken
puts "space taken can not block 2: " + answer.to_s
else
puts answer.to_s+" blocked"
#move = answer # for test - at last intersection value found...return it as move value
return #move
end
end
end
end # END #human_winmoves.each do |k,v|
end
end
If you wanna see the entire player_spec.rb file...
require 'game'
require 'board'
describe 'Player class' do
before (:each) do
#Dry it up
#player_human = Player.new('X')
#player_computer = Player.new('O')
#board = Board.new
#game = Game.new(#player_human, #player_computer, #board)
end
describe 'move_human' do
before (:each) do
# first set up my expectations
#player_human.should_receive(:puts).with("human move...")
#player_human.stub(:gets).and_return("a1")
end
it 'receives cli input and prints text to screen' do
# now trigger them
#player_human.move_human("X", #board)
end
it 'returns a move value' do
# now trigger them
#player_human.move_human("X", #board).should eq(:a1) #return the value is what I mocked?
end
end
describe 'move_computer' do
it 'should print - ...computer move... - to screen' do
# first set up my expectations
#player_computer.should_receive(:puts).with("computer move...")
# now trigger them
#player_computer.move_computer("O", #board)
end
it 'returns expected first move b2' do
#player_computer.move_computer("O", #board).should eq(:b2)
end
end
describe 'attempt_win' do
before (:each) do
#board.grid[:b2] == "X"
end
xit 'computer looks for any possible win move'
it 'computer returns a value' do
#player_computer.attempt_win(#board).should_not be(nil)
end
end
describe 'attempt_block'do
xit 'looks for a block move'
end
end
The error tells you pretty clearly what is wrong, if you know how to read it right:
1) Player class attempt_win computer returns a value
Failure/Error: #player_computer.attempt_win(#board).should_not be(nil)
NoMethodError:
undefined method `each' for nil:NilClass
# ./lib/player.rb:171:in `attempt_win'
# ./spec/player_spec.rb:47:in `block (3 levels) in <top (required)>'
This is telling you several things:
The line of your spec where the error occurred is #player_computer.attempt_win(#board).should_not be(nil).
The error is due to each being called on an object that does not respond to that message.
The object it was called on is nil.
The error occurred at ./lib/player.rb:171 in the attempt_win method, or in some internal library method called by attempt_win. (You can run your spec with the --backtrace flag to get the full backtrace. By default, RSpec tries to filter it to only the relevant lines to reduce noise.)
Looking at your code, the error suggests that #ai_winmoves has not been initialized and had the value of nil when attempt_win was called.

Cooler ASCII Spinners? [closed]

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.

Resources