I was implementing Command-line arguments with C , And I shocked when the Arguments Array start acting strange when it passes the number of the argument given. here is the code :
#include <stdio.h>
int main(int a, char *arra[]){
/*
for(int i = 1;i<a;i++){
printf("Arguments N%d -> %s\n",i+1,arra[i]);
}
printf("Totale Arguments:%d\n",a-1);
*/
for(int i = 0;i<=49 ;i++){
printf("%d: -> %s\n--------------------------------------
------\n",i,arra[i]);
}
return 0;
}
My question is how did the array have access to the Linux Terminal variable like the Path variable PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
And the Output was like :
0: -> ./list
--------------------------------------------
1: -> hi
--------------------------------------------
2: -> 234
--------------------------------------------
3: -> hello
--------------------------------------------
4: -> (null)
--------------------------------------------
5: -> LS_COLORS=rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=00:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arc=01;31:*.arj=01;31:*.taz=01;31:*.lha=01;31:*.lz4=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.tzo=01;31:*.t7z=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:*.lrz=01;31:*.lz=01;31:*.lzo=01;31:*.xz=01;31:*.zst=01;31:*.tzst=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.alz=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.cab=01;31:*.wim=01;31:*.swm=01;31:*.dwm=01;31:*.esd=01;31:*.jpg=01;35:*.jpeg=01;35:*.mjpg=01;35:*.mjpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.m4a=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.oga=00;36:*.opus=00;36:*.spx=00;36:*.xspf=00;36:
--------------------------------------------
6: -> XDG_MENU_PREFIX=gnome-
--------------------------------------------
7: -> LANG=en_US.UTF-8
--------------------------------------------
8: -> GDM_LANG=en_US.UTF-8
--------------------------------------------
9: -> DISPLAY=:1
--------------------------------------------
10: -> COLORTERM=truecolor
--------------------------------------------
11: -> USERNAME=root
--------------------------------------------
12: -> XDG_VTNR=2
--------------------------------------------
13: -> SSH_AUTH_SOCK=/run/user/0/keyring/ssh
--------------------------------------------
14: -> XDG_SESSION_ID=7
--------------------------------------------
15: -> USER=root
--------------------------------------------
16: -> DESKTOP_SESSION=gnome
--------------------------------------------
17: -> GNOME_TERMINAL_SCREEN=/org/gnome/Terminal/screen/bbdf3fc7_241a_437d_86d0_982594cbb92d
--------------------------------------------
18: -> PWD=/root/Documents/Programming/c
--------------------------------------------
19: -> HOME=/root
--------------------------------------------
20: -> SSH_AGENT_PID=1581
--------------------------------------------
21: -> QT_ACCESSIBILITY=1
--------------------------------------------
22: -> XDG_SESSION_TYPE=x11
--------------------------------------------
23: -> XDG_DATA_DIRS=/usr/share/gnome:/usr/local/share/:/usr/share/
--------------------------------------------
24: -> XDG_SESSION_DESKTOP=gnome
--------------------------------------------
25: -> GJS_DEBUG_OUTPUT=stderr
--------------------------------------------
26: -> GTK_MODULES=gail:atk-bridge
--------------------------------------------
27: -> WINDOWPATH=2
--------------------------------------------
28: -> TERM=xterm-256color
--------------------------------------------
29: -> SHELL=/bin/bash
--------------------------------------------
30: -> VTE_VERSION=5202
--------------------------------------------
31: -> XDG_CURRENT_DESKTOP=GNOME
--------------------------------------------
32: -> GPG_AGENT_INFO=/run/user/0/gnupg/S.gpg-agent:0:1
--------------------------------------------
33: -> GNOME_TERMINAL_SERVICE=:1.67
--------------------------------------------
34: -> SHLVL=1
--------------------------------------------
35: -> XDG_SEAT=seat0
--------------------------------------------
36: -> GDMSESSION=gnome
--------------------------------------------
37: -> GNOME_DESKTOP_SESSION_ID=this-is-deprecated
--------------------------------------------
38: -> LOGNAME=root
--------------------------------------------
39: -> DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/0/bus
--------------------------------------------
40: -> XDG_RUNTIME_DIR=/run/user/0
--------------------------------------------
41: -> XAUTHORITY=/run/user/0/gdm/Xauthority
--------------------------------------------
42: -> PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
--------------------------------------------
43: -> GJS_DEBUG_TOPICS=JS ERROR;JS LOG
--------------------------------------------
44: -> SESSION_MANAGER=local/FXMACO:#/tmp/.ICE-unix/1529,unix/FXMACO:/tmp/.ICE-unix/1529
--------------------------------------------
45: -> _=./list
--------------------------------------------
46: -> OLDPWD=/root/Documents/Books
--------------------------------------------
47: -> (null)
--------------------------------------------
Segmentation fault
for(int i = 0;i<=49 ;i++){
as we see here your argument list is shorter than 50 elements
It is good to use standard names and to take into the account number of arguments passed (that is the reason of the argc)
int main(int argc char *argv[])
{
for(int i = 0;i < argc ;i++){
Related
I am trying to write a program in OAMulator that is reflective of this Pseudo-code.
Set highest to 0
Set count to 7
While count > 0
Get newScore
Print newScore
If newScore > highest
Set highest to newScore
Set count to count - 1
Print highest
Stop
This is what I've come up with. We have to use 7 scores and get the highest and print only the highest score. We also have to use a count loop. I entered 0 as a control to start the inputs along with 7 other scores. TO BE CLEAR I AM NOT LOOKING FOR THE AWNSER OR SOLUTION. i am looking to learn why this isnt working and how to make a count loop work with a higherthan loop.
INPUT LIST
0
60
70
80
90
83
76
95
Then I wrote the code as best as I could, but the issue I run into is the count and new score run off the Accumulator. I tried writing another loop to change it but then the two loops don't always run and the count gets messed up or the scores don't get tallied right.
SET 7 #set count to 7
count, STA 100 #store count to slot 100
loopstart, LDA 0 #start loop, load 0
STA 101 #store 0 in slot 101
LDA 0 #load 60
STA 102 #store in slot 102
LDA 101 #load 60
SUB 102 #subract 70
BRP loopstart #if pos then loop, if not go on.
LDA 100 #load count
DEC # count -1
BRP count #if count <0 loop to count
print, STA 102 #print highest
HLT
here is the trace and memory
TRACE
0: PC=1 IR=[?????] AR=? ACC=? B=?
1: PC=2 IR=[SET 7] AR=1 ACC=7 B=?
2: PC=3 IR=[STA 100] AR=100 ACC=7 B=?
3: PC=4 IR=[LDA 0] AR=0 ACC=0 B=?
4: PC=5 IR=[STA 101] AR=101 ACC=0 B=?
5: PC=6 IR=[LDA 0] AR=0 ACC=60 B=?
6: PC=7 IR=[STA 102] AR=102 ACC=60 B=?
7: PC=8 IR=[LDA 101] AR=101 ACC=0 B=?
8: PC=9 IR=[SUB 102] AR=102 ACC=-60 B=60
9: PC=10 IR=[BRP 3] AR=9 ACC=-60 B=60
10: PC=11 IR=[LDA 100] AR=100 ACC=7 B=60
11: PC=12 IR=[DEC] AR=11 ACC=6 B=60
12: PC=2 IR=[BRP 2] AR=12 ACC=6 B=60
13: PC=3 IR=[STA 100] AR=100 ACC=6 B=60
14: PC=4 IR=[LDA 0] AR=0 ACC=70 B=60
15: PC=5 IR=[STA 101] AR=101 ACC=70 B=60
16: PC=6 IR=[LDA 0] AR=0 ACC=80 B=60
17: PC=7 IR=[STA 102] AR=102 ACC=80 B=60
18: PC=8 IR=[LDA 101] AR=101 ACC=70 B=60
19: PC=9 IR=[SUB 102] AR=102 ACC=-10 B=80
20: PC=10 IR=[BRP 3] AR=9 ACC=-10 B=80
21: PC=11 IR=[LDA 100] AR=100 ACC=6 B=80
22: PC=12 IR=[DEC] AR=11 ACC=5 B=80
23: PC=2 IR=[BRP 2] AR=12 ACC=5 B=80
24: PC=3 IR=[STA 100] AR=100 ACC=5 B=80
25: PC=4 IR=[LDA 0] AR=0 ACC=90 B=80
26: PC=5 IR=[STA 101] AR=101 ACC=90 B=80
27: PC=6 IR=[LDA 0] AR=0 ACC=83 B=80
28: PC=7 IR=[STA 102] AR=102 ACC=83 B=80
29: PC=8 IR=[LDA 101] AR=101 ACC=90 B=80
30: PC=9 IR=[SUB 102] AR=102 ACC=7 B=83
31: PC=3 IR=[BRP 3] AR=9 ACC=7 B=83
32: PC=4 IR=[LDA 0] AR=0 ACC=76 B=83
33: PC=5 IR=[STA 101] AR=101 ACC=76 B=83
34: PC=6 IR=[LDA 0] AR=0 ACC=95 B=83
35: PC=7 IR=[STA 102] AR=102 ACC=95 B=83
36: PC=8 IR=[LDA 101] AR=101 ACC=76 B=83
37: PC=9 IR=[SUB 102] AR=102 ACC=-19 B=95
38: PC=10 IR=[BRP 3] AR=9 ACC=-19 B=95
39: PC=11 IR=[LDA 100] AR=100 ACC=5 B=95
40: PC=12 IR=[DEC] AR=11 ACC=4 B=95
41: PC=2 IR=[BRP 2] AR=12 ACC=4 B=95
42: PC=3 IR=[STA 100] AR=100 ACC=4 B=95
Error: Attempt to read missing input
43: PC=4 IR=[LDA 0] AR=0 ACC=? B=95
Abort: 43 instructions executed.
MEMORY
1. SET 7
2. STA 100
3. LDA 0
4. STA 101
5. LDA 0
6. STA 102
7. LDA 101
8. SUB 102
9. BRP 3
10. LDA 100
11. DEC
12. BRP 2
13. STA 102
14. HLT
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39.
40.
41.
42.
43.
44.
45.
46.
47.
48.
49.
50.
51.
52.
53.
54.
55.
56.
57.
58.
59.
60.
61.
62.
63.
64.
65.
66.
67.
68.
69.
70.
71.
72.
73.
74.
75.
76.
77.
78.
79.
80.
81.
82.
83.
84.
85.
86.
87.
88.
89.
90.
91.
92.
93.
94.
95.
96.
97.
98.
99.
100. 4
101. 76
102. 95
I figured it out. It took me hours. almost days.
SET 8 #set count to 8
STA 100 #store in slot 100
SET 0
STA 102 #slot 0 as highest
loopstart, LDA 100 #Load count
DEC #count -1
BRZ print # if count is 0 print
STA 100 # if count is more than 1 store
LDA 0 #load ACC
STA 101 #store ACC in 101
LDA 101 #load Number
SUB 102 #subract highest
BRP while
BR loopstart
print, LDA 102
STA 0
HLT
while, LDA 101
STA 102 #if ACC is positive store as highest
BR loopstart
There doesn't seem to be much help on the internet for OAM assembly language so i posted the answer for others in the future.
I am trying to install Bitnami Redmine 4.1.1-8 on a MS SQL 2107 server from a Windows 10 Pro computer.
This is a clean computer with no other versions of Redmine. Unfortunately, every time I try to execute the command bundle exec thin -e production start I get this error:
C:\Bitnami\redmine-4.1.1-8\apps\redmine\htdocs> bundle exec thin -e production start
Using rack adapter
Traceback (most recent call last):
86: from C:/Bitnami/redmine-4.1.1-8/apps/redmine/htdocs/vendor/bundle/ruby/2.5.0/bin/thin:23:in <main>'
85: from C:/Bitnami/redmine-4.1.1-8/apps/redmine/htdocs/vendor/bundle/ruby/2.5.0/bin/thin:23:inload'
84: from C:/Bitnami/redmine-4.1.1-8/apps/redmine/htdocs/vendor/bundle/ruby/2.5.0/gems/thin-1.7.2-x64-mingw32/bin/thin:6:in <top (required)>'
83: from C:/Bitnami/redmine-4.1.1-8/apps/redmine/htdocs/vendor/bundle/ruby/2.5.0/gems/thin-1.7.2-x64-mingw32/lib/thin/runner.rb:159:inrun!'
82: from C:/Bitnami/redmine-4.1.1-8/apps/redmine/htdocs/vendor/bundle/ruby/2.5.0/gems/thin-1.7.2-x64-mingw32/lib/thin/runner.rb:203:in run_command'
81: from C:/Bitnami/redmine-4.1.1-8/apps/redmine/htdocs/vendor/bundle/ruby/2.5.0/gems/thin-1.7.2-x64-mingw32/lib/thin/controllers/controller.rb:74:instart'
80: from C:/Bitnami/redmine-4.1.1-8/apps/redmine/htdocs/vendor/bundle/ruby/2.5.0/gems/thin-1.7.2-x64-mingw32/lib/thin/controllers/controller.rb:170:in load_adapter'
79: from C:/Bitnami/redmine-4.1.1-8/apps/redmine/htdocs/vendor/bundle/ruby/2.5.0/gems/thin-1.7.2-x64-mingw32/lib/rack/adapter/loader.rb:42:infor'
78: from C:/Bitnami/redmine-4.1.1-8/apps/redmine/htdocs/vendor/bundle/ruby/2.5.0/gems/thin-1.7.2-x64-mingw32/lib/rack/adapter/loader.rb:33:in load'
77: from C:/Bitnami/redmine-4.1.1-8/apps/redmine/htdocs/vendor/bundle/ruby/2.5.0/gems/thin-1.7.2-x64-mingw32/lib/rack/adapter/loader.rb:33:ineval'
76: from C:/Bitnami/redmine-4.1.1-8/apps/redmine/htdocs/config.ru:1:in <main>'
75: from C:/Bitnami/redmine-4.1.1-8/apps/redmine/htdocs/config.ru:1:innew'
74: from C:/Bitnami/redmine-4.1.1-8/apps/redmine/htdocs/vendor/bundle/ruby/2.5.0/gems/rack-2.2.3/lib/rack/builder.rb:125:in initialize'
73: from C:/Bitnami/redmine-4.1.1-8/apps/redmine/htdocs/vendor/bundle/ruby/2.5.0/gems/rack-2.2.3/lib/rack/builder.rb:125:ininstance_eval'
72: from C:/Bitnami/redmine-4.1.1-8/apps/redmine/htdocs/config.ru:3:in block in <main>'
71: from C:/Bitnami/redmine-4.1.1-8/apps/redmine/htdocs/config.ru:3:inrequire'
70: from C:/Bitnami/redmine-4.1.1-8/apps/redmine/htdocs/config/environment.rb:16:in <top (required)>'
69: from C:/Bitnami/redmine-4.1.1-8/apps/redmine/htdocs/vendor/bundle/ruby/2.5.0/gems/railties-5.2.4.2/lib/rails/application.rb:361:ininitialize!'
68: from C:/Bitnami/redmine-4.1.1-8/apps/redmine/htdocs/vendor/bundle/ruby/2.5.0/gems/railties-5.2.4.2/lib/rails/initializable.rb:60:in run_initializers'
67: from C:/Bitnami/redmine-4.1.1-8/ruby/lib/ruby/2.5.0/tsort.rb:205:intsort_each'
66: from C:/Bitnami/redmine-4.1.1-8/ruby/lib/ruby/2.5.0/tsort.rb:226:in tsort_each'
65: from C:/Bitnami/redmine-4.1.1-8/ruby/lib/ruby/2.5.0/tsort.rb:347:ineach_strongly_connected_component'
64: from C:/Bitnami/redmine-4.1.1-8/ruby/lib/ruby/2.5.0/tsort.rb:347:in call'
63: from C:/Bitnami/redmine-4.1.1-8/ruby/lib/ruby/2.5.0/tsort.rb:347:ineach'
62: from C:/Bitnami/redmine-4.1.1-8/ruby/lib/ruby/2.5.0/tsort.rb:349:in block in each_strongly_connected_component'
61: from C:/Bitnami/redmine-4.1.1-8/ruby/lib/ruby/2.5.0/tsort.rb:431:ineach_strongly_connected_component_from'
60: from C:/Bitnami/redmine-4.1.1-8/ruby/lib/ruby/2.5.0/tsort.rb:350:in block (2 levels) in each_strongly_connected_component'
59: from C:/Bitnami/redmine-4.1.1-8/ruby/lib/ruby/2.5.0/tsort.rb:228:inblock in tsort_each'
58: from C:/Bitnami/redmine-4.1.1-8/apps/redmine/htdocs/vendor/bundle/ruby/2.5.0/gems/railties-5.2.4.2/lib/rails/initializable.rb:61:in block in run_initializers'
57: from C:/Bitnami/redmine-4.1.1-8/apps/redmine/htdocs/vendor/bundle/ruby/2.5.0/gems/railties-5.2.4.2/lib/rails/initializable.rb:32:inrun'
56: from C:/Bitnami/redmine-4.1.1-8/apps/redmine/htdocs/vendor/bundle/ruby/2.5.0/gems/railties-5.2.4.2/lib/rails/initializable.rb:32:in instance_exec'
55: from C:/Bitnami/redmine-4.1.1-8/apps/redmine/htdocs/vendor/bundle/ruby/2.5.0/gems/railties-5.2.4.2/lib/rails/application/finisher.rb:69:inblock in '
54: from C:/Bitnami/redmine-4.1.1-8/apps/redmine/htdocs/vendor/bundle/ruby/2.5.0/gems/railties-5.2.4.2/lib/rails/application/finisher.rb:69:in each'
53: from C:/Bitnami/redmine-4.1.1-8/apps/redmine/htdocs/vendor/bundle/ruby/2.5.0/gems/railties-5.2.4.2/lib/rails/engine.rb:356:ineager_load!'
52: from C:/Bitnami/redmine-4.1.1-8/apps/redmine/htdocs/vendor/bundle/ruby/2.5.0/gems/railties-5.2.4.2/lib/rails/engine.rb:475:in eager_load!'
51: from C:/Bitnami/redmine-4.1.1-8/apps/redmine/htdocs/vendor/bundle/ruby/2.5.0/gems/railties-5.2.4.2/lib/rails/engine.rb:475:ineach'
50: from C:/Bitnami/redmine-4.1.1-8/apps/redmine/htdocs/vendor/bundle/ruby/2.5.0/gems/railties-5.2.4.2/lib/rails/engine.rb:477:in block in eager_load!'
49: from C:/Bitnami/redmine-4.1.1-8/apps/redmine/htdocs/vendor/bundle/ruby/2.5.0/gems/railties-5.2.4.2/lib/rails/engine.rb:477:ineach'
48: from C:/Bitnami/redmine-4.1.1-8/apps/redmine/htdocs/vendor/bundle/ruby/2.5.0/gems/railties-5.2.4.2/lib/rails/engine.rb:478:in block (2 levels) in eager_load!'
47: from C:/Bitnami/redmine-4.1.1-8/apps/redmine/htdocs/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.4.2/lib/active_support/dependencies.rb:246:inrequire_dependency'
46: from C:/Bitnami/redmine-4.1.1-8/apps/redmine/htdocs/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.4.2/lib/active_support/dependencies.rb:334:in depend_on'
45: from C:/Bitnami/redmine-4.1.1-8/apps/redmine/htdocs/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.4.2/lib/active_support/dependencies.rb:356:inrequire_or_load'
44: from C:/Bitnami/redmine-4.1.1-8/apps/redmine/htdocs/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.4.2/lib/active_support/dependencies.rb:37:in load_interlock'
43: from C:/Bitnami/redmine-4.1.1-8/apps/redmine/htdocs/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.4.2/lib/active_support/dependencies/interlock.rb:13:inloading'
42: from C:/Bitnami/redmine-4.1.1-8/apps/redmine/htdocs/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.4.2/lib/active_support/concurrency/share_lock.rb:151:in exclusive'
41: from C:/Bitnami/redmine-4.1.1-8/apps/redmine/htdocs/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.4.2/lib/active_support/dependencies/interlock.rb:14:inblock in loading'
40: from C:/Bitnami/redmine-4.1.1-8/apps/redmine/htdocs/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.4.2/lib/active_support/dependencies.rb:37:in block in load_interlock'
39: from C:/Bitnami/redmine-4.1.1-8/apps/redmine/htdocs/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.4.2/lib/active_support/dependencies.rb:378:inblock in require_or_load'
38: from C:/Bitnami/redmine-4.1.1-8/apps/redmine/htdocs/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.4.2/lib/active_support/dependencies.rb:291:in require'
37: from C:/Bitnami/redmine-4.1.1-8/apps/redmine/htdocs/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.4.2/lib/active_support/dependencies.rb:257:inload_dependency'
36: from C:/Bitnami/redmine-4.1.1-8/apps/redmine/htdocs/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.4.2/lib/active_support/dependencies.rb:291:in block in require'
35: from C:/Bitnami/redmine-4.1.1-8/apps/redmine/htdocs/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.4.2/lib/active_support/dependencies.rb:291:inrequire'
34: from C:/Bitnami/redmine-4.1.1-8/apps/redmine/htdocs/app/models/issue_query.rb:20:in <top (required)>'
33: from C:/Bitnami/redmine-4.1.1-8/apps/redmine/htdocs/app/models/issue_query.rb:36:in'
32: from C:/Bitnami/redmine-4.1.1-8/apps/redmine/htdocs/app/models/issue_query.rb:36:in new'
31: from C:/Bitnami/redmine-4.1.1-8/apps/redmine/htdocs/app/models/query.rb:31:ininitialize'
30: from C:/Bitnami/redmine-4.1.1-8/apps/redmine/htdocs/app/models/query.rb:91:in groupable'
29: from C:/Bitnami/redmine-4.1.1-8/apps/redmine/htdocs/app/models/user.rb:816:incurrent'
28: from C:/Bitnami/redmine-4.1.1-8/apps/redmine/htdocs/app/models/user.rb:822:in anonymous'
27: from C:/Bitnami/redmine-4.1.1-8/apps/redmine/htdocs/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/scoping/default.rb:34:inunscoped'
26: from C:/Bitnami/redmine-4.1.1-8/apps/redmine/htdocs/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/core.rb:287:in relation'
25: from C:/Bitnami/redmine-4.1.1-8/apps/redmine/htdocs/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/inheritance.rb:84:infinder_needs_type_condition?'
24: from C:/Bitnami/redmine-4.1.1-8/apps/redmine/htdocs/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/inheritance.rb:78:in descends_from_active_record?'
23: from C:/Bitnami/redmine-4.1.1-8/apps/redmine/htdocs/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/model_schema.rb:336:incolumns_hash'
22: from C:/Bitnami/redmine-4.1.1-8/apps/redmine/htdocs/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/model_schema.rb:456:in load_schema'
21: from C:/Bitnami/redmine-4.1.1-8/ruby/lib/ruby/2.5.0/monitor.rb:235:inmon_synchronize'
20: from C:/Bitnami/redmine-4.1.1-8/apps/redmine/htdocs/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/model_schema.rb:459:in block in load_schema'
19: from C:/Bitnami/redmine-4.1.1-8/apps/redmine/htdocs/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/attribute_decorators.rb:51:inload_schema!'
18: from C:/Bitnami/redmine-4.1.1-8/apps/redmine/htdocs/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/attributes.rb:234:in load_schema!'
17: from C:/Bitnami/redmine-4.1.1-8/apps/redmine/htdocs/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/model_schema.rb:466:inload_schema!'
16: from C:/Bitnami/redmine-4.1.1-8/apps/redmine/htdocs/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/connection_handling.rb:90:in connection'
15: from C:/Bitnami/redmine-4.1.1-8/apps/redmine/htdocs/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/connection_handling.rb:118:inretrieve_connection'
14: from C:/Bitnami/redmine-4.1.1-8/apps/redmine/htdocs/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:1033:in retrieve_connection'
13: from C:/Bitnami/redmine-4.1.1-8/apps/redmine/htdocs/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:382:inconnection'
12: from C:/Bitnami/redmine-4.1.1-8/apps/redmine/htdocs/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:538:in checkout'
11: from C:/Bitnami/redmine-4.1.1-8/apps/redmine/htdocs/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:814:inacquire_connection'
10: from C:/Bitnami/redmine-4.1.1-8/apps/redmine/htdocs/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:853:in try_to_checkout_new_connection'
9: from C:/Bitnami/redmine-4.1.1-8/apps/redmine/htdocs/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:874:incheckout_new_connection'
8: from C:/Bitnami/redmine-4.1.1-8/apps/redmine/htdocs/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.4.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:830:in new_connection'
7: from C:/Bitnami/redmine-4.1.1-8/apps/redmine/htdocs/vendor/bundle/ruby/2.5.0/gems/activerecord-sqlserver-adapter-5.2.1/lib/active_record/sqlserver_base.rb:13:insqlserver_connection'
6: from C:/Bitnami/redmine-4.1.1-8/apps/redmine/htdocs/vendor/bundle/ruby/2.5.0/gems/activerecord-sqlserver-adapter-5.2.1/lib/active_record/sqlserver_base.rb:13:in new'
5: from C:/Bitnami/redmine-4.1.1-8/apps/redmine/htdocs/vendor/bundle/ruby/2.5.0/gems/activerecord-sqlserver-adapter-5.2.1/lib/active_record/connection_adapters/sqlserver_adapter.rb:64:ininitialize'
4: from C:/Bitnami/redmine-4.1.1-8/apps/redmine/htdocs/vendor/bundle/ruby/2.5.0/gems/activerecord-sqlserver-adapter-5.2.1/lib/active_record/connection_adapters/sqlserver_adapter.rb:365:in connect'
3: from C:/Bitnami/redmine-4.1.1-8/apps/redmine/htdocs/vendor/bundle/ruby/2.5.0/gems/activerecord-sqlserver-adapter-5.2.1/lib/active_record/connection_adapters/sqlserver_adapter.rb:379:indblib_connect'
2: from C:/Bitnami/redmine-4.1.1-8/apps/redmine/htdocs/vendor/bundle/ruby/2.5.0/gems/activerecord-sqlserver-adapter-5.2.1/lib/active_record/connection_adapters/sqlserver_adapter.rb:379:in new'
1: from C:/Bitnami/redmine-4.1.1-8/apps/redmine/htdocs/vendor/bundle/ruby/2.5.0/gems/tiny_tds-2.1.3-x64-mingw32/lib/tiny_tds/client.rb:60:ininitialize'
C:/Bitnami/redmine-4.1.1-8/apps/redmine/htdocs/vendor/bundle/ruby/2.5.0/gems/tiny_tds-2.1.3-x64-mingw32/lib/tiny_tds/client.rb:60:in `connect': Unable to connect: Adaptive Server is unavailable or does not exist (127.0.0.1) (TinyTds::Error)
Here's my full database/yml file:
production:
adapter: sqlserver
host: 127.0.0.1
port: 1433
database: DATABESE
username: user
password: "passwordpassword"
encoding: utf8
I am trying to install the program on a production MS SQL server of our company so that we can keep track of the employees activities, and I would be grateful for any help.
Quite by accident, I managed to solve this problem myself.
It is necessary to specify the DNS server name, and not its IP, as I did.
After making all the changes to the adapter and connecting to the SQL server, you must run the procedure bundle update
After this shut dawn all server connections from Bitnami Stack Manager Tool
Run bundle exec rake db:migrate RAILS_ENV=production
Re-start all server connections from Bitnami Stack Manager Tool
And that's all about it.
I've got data coming from mysql and some values have leading or trailing spaces.
This is the code I have:
IFS=$':' res=(${vals//$'\t'/:})
for (( i=0 ; i<${#res[#]} ; i++ )); do
echo "$i: ${res[i]}*"
done
is there a simple effective way to ensure there are no leading or trailing space in res[i] ?
Thanks
EDIT
This is the result of my MYSQL query before it goes through IFS.
ZnbMF0 9RrO7 1 SiteA password password 12 1234 1234 456 456 0 0 0 0 0 0 0 0 test#domain.com test user 5 2222 0 0 0 0 server address 0 0 test#domain.com 0 0 0 0 0 0 0 0 0 0 0 0 0 NULL
In MySQL the email addresses have leading and trailing spaces.
Processing through IFS and then Looping though it as :
for (( i=0 ; i<${#res[#]} ; i++ )); do
echo "$i: ${res[i]}*"
done
Results in:
0: ZnbMFO*
1: 9RrO7*
2: 1*
3: SiteA*
4: password*
5: password*
6: 12*
7: 1234*
8: 1234*
9: 456*
10: 456*
11: 0*
12: 0*
13: 0*
14: 0*
15: 0 *
16: 0*
17: 0*
18: 0*
19: test#domain.com *
20: test*
21: user*
22: 5*
23: 2222 *
24: 0*
25: 0 *
26: 0*
27: 0*
28: server*
29: address*
30: 0*
31: 0*
32: test#domain.com *
33: 0*
34: 0*
35: 0*
36: 0*
37: 0*
38: 0*
39: 0 *
40: 0*
41: 0*
42: 0*
43: 0 *
44: 0*
45: 0*
46: NULL*
The * is there just to highlight the trailing space.
Thanks
Let's say you have an array as this one:
arr=('foo bar' 'test#domain.com ' \
' test#domain.com ' ' test#domain.com ')
To check array content using printf:
printf '[%s]\n' "${arr[#]}"
This will show:
[foo bar]
[test#domain.com ]
[ test#domain.com ]
[ test#domain.com ]
Now for leading and trailing space removal:
shopt -s extglob # turn on extended glob
arr=( "${arr[#]/#+([[:blank:]])/}" ) # remove leading space/tab from each element
arr=( "${arr[#]/%+([[:blank:]])/}" ) # remove trailing space/tab from each element
Now if you print array again:
printf '[%s]\n' "${arr[#]}"
It will show:
[foo bar]
[test#domain.com]
[test#domain.com]
[test#domain.com]
Not sure if you would call it simple, but you can use sed:
echo "${res[i]}" | sed 's/^ *\| *$//g'
vals=$' a \t c d'
IFS=$':' res=(${vals//$'\t'/:})
for (( i=0 ; i<${#res[#]} ; i++ )); do
echo X${res[i]}X
res[$i]=$(echo "${res[i]}" | sed 's/^ *\| *$//g')
echo X${res[i]}X
done
Output:
X a X
XaX
X c dX
Xc dX
I have a array and I want to melt it based on the dimnames. The problem is that the dimension names are large numeric values and therefore making them character would convert them to a wrong ID see the example:
test <- array(1:18, dim = c(3,3,2), dimnames = list(c(00901291282245454545454,329293929929292,2929992929922929),
c("a", "b", "c"),
c("d", "e")))
library(reshape2)
library(data.table)
test2 <- data.table(melt(test))
test2[, Var1 := as.character(Var1)]
> test2
Var1 Var2 Var3 value
1: 9.01291282245455e+20 a d 1
2: 329293929929292 a d 2
3: 2929992929922929 a d 3
4: 9.01291282245455e+20 b d 4
5: 329293929929292 b d 5
6: 2929992929922929 b d 6
7: 9.01291282245455e+20 c d 7
8: 329293929929292 c d 8
9: 2929992929922929 c d 9
10: 9.01291282245455e+20 a e 10
11: 329293929929292 a e 11
12: 2929992929922929 a e 12
13: 9.01291282245455e+20 b e 13
14: 329293929929292 b e 14
15: 2929992929922929 b e 15
16: 9.01291282245455e+20 c e 16
17: 329293929929292 c e 17
18: 2929992929922929 c e 18
How could I make the first column with the large IDs character? What I am currently doing is pasting a character letter to the dimnames and then melt, making it a character and then take a substring, which is really inefficient. It is important that it is an efficient solution because the dataset is millions of rows. There are two problems,first the 0's are deleted if they are in front of the ID and it is converted to a e+20 character.
You need to define your dimnames as character and then slighly modify melt.array which is called when you do melt on your array:
test <- array(1:18, dim = c(3,3,2), dimnames = list(c("00901291282245454545454", "329293929929292", "2929992929922929"),
c("a", "b", "c"),
c("d", "e")))
Customise melt.array to add a parameter which permits to decide wether you want the conversion or not:
melt.array2 <- function (data, varnames = names(dimnames(data)), conv=TRUE, ...)
{
values <- as.vector(data)
dn <- dimnames(data)
if (is.null(dn))
dn <- vector("list", length(dim(data)))
dn_missing <- sapply(dn, is.null)
dn[dn_missing] <- lapply(dim(data), function(x) 1:x)[dn_missing]
if(conv){ # conv is the new parameter to know if conversion needs to be done
char <- sapply(dn, is.character)
dn[char] <- lapply(dn[char], type.convert)
}
indices <- do.call(expand.grid, dn)
names(indices) <- varnames
data.frame(indices, value = values)
}
Try the new function on your example (with conv=FALSE):
head(melt.array2(test, conv=FALSE))
# X1 X2 X3 value
# 1 00901291282245454545454 a d 1
# 2 329293929929292 a d 2
# 3 2929992929922929 a d 3
# 4 00901291282245454545454 b d 4
# 5 329293929929292 b d 5
# 6 2929992929922929 b d 6
EDIT
In the development version of reshape2 (devtools::install_github("hadley/reshape"), melt.array is differently defined and you can use parameter as.is to avoid the conversion:
melt(test, as.is=TRUE)
will give you the same result as above (with Var1 etc instead of X1 etc).
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
A palindrome date is given and we have to find the closest palindrome date of this given date. The result date should be before the given date.
Date is in the format of YYYY/MM/DD.
One brute force solution is (pseudo-code is given which might not be efficient).
Convert the string into a number
For each number less than this number
If the number is a valid date then
If number is a palindrome
print and return
I think there must be some efficient algorithm to solve this problem.
Example: Input date: 2030/03/02
Output date: 2021/12/02
If you consider that a palindrome date is written as YYYY/MM/DD, like 2121/12/12, you can make some conclusions:
A day in the month is between 01 and 31 and a month between 01 and 12. So you deduce that a date palindrome matches the following regex:
([0-9][0-2]|[01]3)([0-9]0|[12]1)-(0[0-9]|1[12])-([0-2][0-9]|3[01])
1. & 2. 3 & 4 4 & 3 2 & 1
I have marked the four letters which repeat
The palindrome before the inputted date would be
decrementing if possible n°4 (last year and ten month before)
Or
decrementing if possible number n°3 (10 years and 1 month before)
Or
decrementing if possible number n°2 (100 years and 10 days before)
Or
decrementing if possible number n°1 (1000 years and 1 day before)
Or
Stop
In the given year, there will be only one palindromic date. Hence, to find previous palindromic date, you need to decrement the year and convert it to palindromic date.
Example: for 2030, valid month and day will be 03 and 02 which will lead to 2030/03/02.
So, it must be clear that palindromic date in this case is only possible when:
Year is of 4 digits (not for 10000) as months and number of days are in two digits
Last two digits of years should be {10, 20, 30, 40, 50, 60, 70, 80, 90, 01, 11, 21}
First two digits of years should be mirror image of 1-31 (with month and year validity).
Using rule 2 and 3, it can be checked in O(1) whether a given year has palindromic date or not in the given format. Let us assume that valid range of year is from 9999-0001, then it can be done in linear order to find previous palindromic date.
void find_prev_date(const char* input, char * output) {
int year = extract_year(input); //Extract first 4 digits
--year;
//limit is 101 because 0000 will not give you valid month and day.
for(;year>=101;--year) {
if(haspalindromic(year))
{
write_date(year, output);
}
}
}
bool haspalindromic(int year)
{
int first2 = year%100;
int last2 = year/100;
bool second_valid = false;
bool first_valid = false;
switch(last2){
case 10: case 20: case 30: case 40: case 50: case 60: case 70: case 80:
case 90: case 1: case 11: case 21: second_valid = true; break;
}
if(!second_valid)
return false;
switch(first2) {
case 10: case 20: case 30: case 40: case 50: case 60: case 70: case 80: case 90: case 1: case 11: case 21: case 31: case 41: case 51: case 61: case 71: case 81: case 91:
case 2: case 12: case 22: case 32: case 42: case 52: case 62: case 72: case 82: case 92:
case 3: case 13:
first_valid = true;
break;
}
if(!first_valid)
return false;
//reverse digit such that 2 yields 20
int month = reverse_digits_on100(last2);
int day = reverse_digits_on100(first2);
if(month==2) {
if(day<=28)
return true;
if(isleapyear(year) && day==29)
return true;
if(day>28)
return false;
}
switch(month) {
case 4: case 6: case 9: case 11:
if(day>30)
return false;
}
//For remaining months, check is already made as first part of year is gives day in range of [1..31].
return true;
}
Some functions are not implemented, but their names clearly suggest intents.