Git Product home page Git Product logo

cmdchallenge's Introduction

CMD Challenge

This repository contains the code for the site cmdchallenge.com

Read more about cmdchallenge

Installation

docker-compose build
# For ARM (M1 mac for example) run
#   BUILD_ARCH=arm64 docker-compose build

docker-compose up runcmd --remove-orphans
# For ARM (M1 mac for example) run
#   BUILD_ARCH=arm64 docker-compose up runcmd caddy -V --remove-orphans

# Connect your browser to http://localhost:8181/

Testing

  • cd cmdchallenge && go test ./...

Local development

Static assets

cd site
npm install
npx vite build

Run the server

cd cmdchallenge
# Start the backend the `-dev` option uses an in-memory db.
go run cmd/runcmd/runcmd.go -dev -staticDistDir=../site/dist

Misc

Test a single command:

curl  http://localhost:8181/c/r -X POST -F slug=hello_world -F cmd="echo hello world"

Fetch solutions:

curl http://localhost:8181/c/s?slug=hello_world

Bugs / Suggestions

cmdchallenge's People

Contributors

0ki avatar akamch avatar amboar avatar bryfry avatar crtlib avatar fibo avatar gitunique avatar giuscri avatar jarv avatar joshtriplett avatar mmalchuk avatar n-eq avatar oswaldderiemaecker avatar parththaker avatar reallocf avatar tato69 avatar tvlooy avatar verovan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cmdchallenge's Issues

Replace String in Text

I tried the following response
find . -name *.txt | while read x; do sed -i 's/challenges are difficult//g' ;done

and this generated
Internal Server Error

potential bug in extract_ip_addresses/

It doesn't seem to be accepting

find . -name 'access.log*' | xargs grep -h -E '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}[0-9]' | awk '{print $1}'

But it accepts

find . -name 'access.log*' | xargs grep -h -E '([0-9]{1,3}\.){3}[0-9]{1,3}' | awk '{print $1}'

No touchy the scrollbar!

Fun game. I touched my mouse wheel to look at the scroll back buffer and noticed something is molesting the normal feel/speed of it. Plops on that! Please leave the scroll bars alone.

deleting all files doesn't accept obvious answer

# Delete all of the files in this challenge
# directory including all subdirectories and
# their contents.
# 

i responded with rm -rf * and it didn't work. whoami says i'm root so... either i'm missing something obvious... or this isn't working right

it responded with False though, which is odd...

bash(0)> rm -rf *
False

access.log is not there

I'm on the initial exercises where I'm supposed to search for patterns within the files starting with "access.log" and I've tried several commands that didn't work but they all work on my local pc.

The error message says that the file access.log doesn't exist.

list_files example doesn't allow "ls -l"

Normal GNU ls doesn't display one file per line but puts multiple files onto the same line. That's why I thought you specifically asked for ls -l but I was suprised it didn't work. Then I tried ls -l | cut -d" " -f9-, maybe you only wanted the file names, but that didn't work either.

this fails

bash(124)> grep -Ril "500" /var/challenges/search_for_files_containing_string
/var/challenges/search_for_files_containing_string/access.log
/var/challenges/search_for_files_containing_string/access.log.1
/var/challenges/search_for_files_containing_string/README

Print Number Sequence

This seems to be a valid answer to the challenge "Print Number Sequence"
echo {1,2,3,4,5,6,7,8,9} {1,2,3,4,5,6,7,8,9}{0,1,2,3,4,5,6,7,8,9,0} 100

Search for Files Containing String should have multiple correct answers.

Expected behavior

Given the following instructions for the module search_for_files_containing_string:

# Print all files, one per line that contain
# the string "500".

The command:

grep -l 500 ./*

Which outputs:

./README
./access.log
./access.log.1

Should be a valid alternative correct answer.

Observed Behavior

The command:

grep -l 500 *

Which outputs:

README
access.log
access.log.1

is the only valid answer.

Possible Investigation Area

I believe the lines here may be the key.

I'm not sure enough how this is implemented if multiple answers can be correct, however, I believe that the ./ addition to most commands that work on a path is good practice. After all, Explicit is better than implicit.

Color scheme is hard to read

The blue and green colors against the dark background are hard to read, especially the challenge question itself. I think more contrast would help, or maybe make it possible to choose color schemes.

Ctrl + d

The Ctrl + d key combination is a logout command if no characters are present, otherwise it is a delete-forward command.

I got internal server error after rm -rf .??*

Wanted to start testing ... do I gave the rm -rf an .* instead of an .??*
The .* geve a nice error.
Issuing rm -rf .??* yielded an internal error.
Subsequent test shows that it does not digest the .??* pattern

bash(0)> rm -rf *
False
Test failed, files or directories remain.
bash(0)> rm -rf * .*
+ rm -rf README animi.doc atque.wav aut.webm beatae.flac blanditiis.avi consectetur.pdf consequuntur.jpeg corporis.xls deleniti.gif dicta.wav dignissimos.css dignissim
os.jpg dolor.doc dolorem.doc dolorem.xls dolorum.wav error.wav excepturi.png exercitationem.mp3 expedita.jpeg expedita.xls hic.xls id.txt ipsa.xls iusto.gif libero.xls
 maxime.mp3 mollitia.odt necessitatibus.css nisi.avi non.gif numquam.xls odit.doc omnis.txt perspiciatis.mov provident.avi quia.jpg quidem.wav saepe.doc sit.avi suscip
it.wav temporibus.doc totam.avi var voluptates.wav voluptates.xls . .. .config .dont.forget.dotfiles
rm: refusing to remove '.' or '..' directory: skipping '.'
rm: refusing to remove '.' or '..' directory: skipping '..'
bash(1)> rm -rf *
False
Test failed, files or directories remain.
bash(0)> rm -rf * .??*
Internal Server Error
bash(☠️)> 

Unsupported Kernel

The kernel running on the website is 4.7.3, while the oldest barely supported kernel is 4.8.17 with 4.9.6 being suggested.

I would presume the ancient version is due to coreos only having it, but is there any possibility to have a more up to date server?

Sources: https://kernel.org/
[code]uname -a[/code]

EDIT: for that matter, uname has no reason to be exposed :P

New "abort-on-error" set -e functionality breaks "non-matching greps" in chains

I don't think I experienced this before the last update, but since the print_common_lines challenge update, any error in a chain of commands now aborts the rest of the script.
I.E.:

bash(0)> false; echo hi
+ false
bash(1)>

Or, more likely to happen with these tests, a grep that doesn't match (minor spoilers?):

cat somefile | while read line; do grep "otherfile" -e "$line"; done;
+ read line
+ cat somefile
+ grep otherfile -e someline
bash(1)>

One can work around it by adding || true or set +e:

bash(0)> cat somefile | while read line; do grep "otherfile" -e "$line" || true; done;
bash(0)>
bash(0)> set +e; cat somefile | while read line; do grep "otherfile" -e "$line"; done;
bash(0)>

Most of my attempts result in Internal Server Error

I have no idea what I'm doing wrong... It's possible none of these would work, but I've been able to execute things without an error on earlier steps.

# Extract all IP addreses from files that
# that start with "access.log" printing one
# IP address per line.
# 
bash(0)> find . -iname 'access.log*' | xargs egrep -h -o '[0-9]+[.][0-9]+[.][0-9]+[.][0-9]+'
Internal Server Error
bash(☠️)> egrep -h -o '[0-9]+[.][0-9]+[.][0-9]+[.][0-9]+' `find . -iname 'access.log*'`
Internal Server Error
bash(☠️)> grep -h -o '[0-9]+[.][0-9]+[.][0-9]+[.][0-9]+' `find . -iname 'access.log*'`
Internal Server Error
bash(☠️)> for f in `find . -iname 'access.log*'`; do grep -h -o '[0-9]+[.][0-9]+[.][0-9]+[.][0-9]+' $f; done
Internal Server Error
bash(☠️)>

There are a few of the challenges like this that I can't seem to find a command that doesn't produce an internal server error... In 'replace_text_in_files' some lines as simple as echo a are returning an error.

Internal Server Error

bash(☠️)> print "hello world"
Internal Server Error
bash(☠️)> echo
Internal Server Error

stdout is not included in output

For sum_all_numbers, I tried the following:

cat sum-me.txt | tr '\n' '+' | sed 's/\+$//' | bc

For some reason, this prints no output and exits with status 0. echo '1+2+3' | bc outputs 6 as expected, so the only thing I can think of is that the answer is being swallowed somehow.

For whatever it's worth, I eventually wound up solving the challenge with:

echo 42

which I would expect to produce the same output, and which succeeded.

corrupted text solution does not work

bash(0)> cat war_and_peace.txt |sed -e 's#![!]*#!#g'|sed -e 's# !# #'|sed -e 's#! ([a-z])# \1#g'|sed -e 's#([a-z])!([a-z])#\1\2#g'|sed -e 's#!.!#.#'
Command is too long.

Don't understand why this doesn't work..

# You have a new challenge!
# Extract all IP addreses from files that
# that start with "access.log" printing one
# IP address per line.
# 
bash(0)> find . -name access.log* | xargs grep -h 500 | cut -f1 -d' '
69.16.40.148
225.219.54.140
2.71.250.27

print_common_lines: doesn't accept a correct but unsorted answer

Currently, print_common_lines challenge reads:

access.log.1 and access.log.2 are http server logs. Print the IP addresses common to both files, one per line.

The following answer is not accepted:

17.137.186.194
2.71.250.27
28.151.137.59
108.68.174.15

but the following (which is achieved by the same command followed by | sort) is:

108.68.174.15
17.137.186.194
2.71.250.27
28.151.137.59

Issue with remove_extension_from_files

Tried this:
Even though the solutions seems to be correct, no error was thrown.

find . -type f | while read line; do new=echo $line | cut -d. -f2; mv $line .$new 2>/dev/null ; done

Thanks!

print_common_lines needs to be further defined

See below. My first solution is correct to the language in the challenge but was not solving it. So I thought maybe the expectation was numerically sorted, which also did not solve the challenge. Finally, I lexically sorted and that was correct.

For challenges where the stdout is simply compared directly to some solution text (i.e. order matters), the question should outline the order expectations.

There is a similar issue in remove_duplicate_lines in that a simple cat | sort | uniq doesn't work so on a whim, I tried an awk solution that maintained initial order and it was correct.

# You have a new challenge!
# access.log.1 and access.log.2 are http server logs. Print the IP
# addresses common to both files, one per line.
# 
bash(0)> cat access.log.1 access.log.2 | awk '($1 in array) { print $1 }; array[$1]'
17.137.186.194
2.71.250.27
28.151.137.59
108.68.174.15
bash(0)> cat access.log.1 access.log.2 | awk '($1 in array) { print $1 }; array[$1]' | sort -n
2.71.250.27
17.137.186.194
28.151.137.59
108.68.174.15
bash(0)> cat access.log.1 access.log.2 | awk '($1 in array) { print $1 }; array[$1]' | sort 
108.68.174.15
17.137.186.194
2.71.250.27
28.151.137.59
# 👍 👍 👍  Correct!

Spoilers in issues

Can we have an ISSUES file to describe how to file an issue without spoilers, and describe how to get help with specifics outside of the issue, or is that unreasonable for the github repo?

Seeing parts of challenge solutions seems fine, but having the whole thing there ruins my personal curiosity as a user while I'm paying attention to the project as a developer and interested chum.

search_for_string_in_files_recursive

# ************************************
# Print all matching lines (without the filename
# or the file path) in all files under the current
# directory that start with "access.log" that
# contain the string "500".
#

bash(0)> grep -r -h "^access.log" | grep -h -r "500" *
# contain the string "500".
69.16.40.148 - - [09/Jan/2017:22:34:33 +0100] "GET /pages/create HTTP/1.0" 500 3471
225.219.54.140 - - [09/Jan/2017:22:35:30 +0100] "GET /posts/foo?appID=xxxx HTTP/1.0" 500 2477
2.71.250.27 - - [09/Jan/2017:22:41:26 +0100] "GET /pages/create HTTP/1.0" 500 2477```

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.