first push

This commit is contained in:
sweatshirt0 2023-02-23 15:23:38 -05:00
commit c395899009
13 changed files with 346 additions and 0 deletions

7
assoc.lisp Normal file
View File

@ -0,0 +1,7 @@
(setq *print-case* :downcase)
(defparameter *accounts*
'((Admin (sweatshirt))
(User1 (samsepi0l))))
(format t "Admin data: ~a ~%" (assoc 'admin *accounts*))

28
bubblesort.lisp Normal file
View File

@ -0,0 +1,28 @@
(setq *print-case* :downcase)
(defvar li (list 4 8 9 2 1))
(defvar array nil)
(push li array)
(defparameter inc 1)
(defvar next (nth inc li))
(dolist (el li)
(if (> el next)
(progn
(defparameter tmp el)
(setq el next)
(setq next tmp)
(setq inc (+ inc 1))
(if (< (nth (- inc 2) li) el))
(push el array))
(progn
(setq inc (+ inc 1))
(push next array)))
(format t "~a~%" array))
(format t "~a" li)

23
convo.lisp Normal file
View File

@ -0,0 +1,23 @@
(setq *print-case* :downcase)
(format t "Hello there, what is your name? ~%")
(defvar *name* (read))
(defun greetings (name)
(format t "Nice to meet you ~a, i'm emacs. ! ~%" name)
(format t "How is your day? ~%")
(defvar how (read))
(defparameter good 'good)
(defparameter bad 'bad)
(if (eq how good)
(progn
(format t "I'm glad to hear that your day was ~a, ~a! ~%" how name)
(format t "I hope you continue to have a ~a day! Till next time! ~%" how)))
(if (eq how bad)
(progn
(format t "I'm sorry to hear that your day was ~a, ~a... ~%" how name)
(format t "I hope your day is better next time, ~a. ~%" name)))
(format t "That's interesting to hear, ~a. Let's aim for a good day next time! ~%" name))
(greetings *name*)

18
lisp.lisp Normal file
View File

@ -0,0 +1,18 @@
(setq *print-case* :downcase)
(format t "Whats your name? ~%")
(defvar *name* (read))
(defun greetings (name)
(format t "It's nice to meet you, ~a, I'm emacs. ~%" name)
(format t "How are you, ~a? ~%" name)
(defparameter good 'good)
(defvar how (read))
(if (eq how good)
(progn
(format t "I'm glad to hear you are ~a! ~%" how)
(format t "Have a great rest of your day, ~a!" name))
(format t "just because your day was ~a now doesn't mean it will be ~a forever! ~%" how how)))
(greetings *name*)

18
loginv1.lisp Normal file
View File

@ -0,0 +1,18 @@
(setq *print-case* :downcase)
(format t "Enter your username: ")
(defvar *username* (read))
(format t "Enter your password: ")
(defvar *password* (read))
(setq use 'sweatshirt)
(setq pass 'Daemons0!)
(defun varify (username password)
(if (and (eq username use) (eq password pass))
(progn
(format t "Thank you for logging in, ~a! ~%" username)
(format t "Will check again soon! ~%"))
(format t "You are not authorized to use this device, ~a." username)))
(varify *username* *password*)

20
loginv2.lisp Normal file
View File

@ -0,0 +1,20 @@
(setq *print-case* :downcase)
(format t "Username: ")
(defvar *username* (read))
(format t "Password: ")
(defvar *password* (read))
(defvar *user* "sweatshirt")
(defvar *pass* "Daemons0!")
(defparameter *accounts* (list :key 1 :username 'sweatshirt :password 'Daemons0!))
(defparameter user (getf *accounts* :username))
(defparameter pass (getf *accounts* :password))
(if (and (eq *username* user) (eq *password* pass))
(progn
(format t "You are now logged in as, ~a" *username*))
(format t "Something went wrong."))

33
loginv3.lisp Normal file
View File

@ -0,0 +1,33 @@
(setq *print-case* :downcase)
(format t "Username: ")
(defvar *username* (read))
(format t "Password: ")
(defvar *password* (read))
(defparameter *accounts* nil)
(defvar admin1 (list :username 'sweatshirt :password 'Daemons0!))
(defvar user1 (list :username 'samsepi0l :password 'Daemons))
(defvar user2 (list :username 'mogad0n :password 'something))
(push admin1 *accounts*)
(push user1 *accounts*)
(push user2 *accounts*)
(defparameter varify 'false)
(defparameter inc 0)
(dolist (acc *accounts*)
(defparameter check1 (getf (nth inc *accounts*) :username))
(defparameter check2 (getf (nth inc *accounts*) :password))
(if (and (equalp *username* check1) (equalp *password* check2))
(setq varify 'true)
(progn
(setq inc (+ inc 1)))))
(if (equalp varify 'true)
(progn
(format t "Thank you so much for logging in, ~a~%" *username*))
(format t "try again~%"))

13
loop-practice.lisp Normal file
View File

@ -0,0 +1,13 @@
(defvar *print-case* :downcase)
(defvar admin (list :username "sweatshirt" :password "Daemons0!"))
(defvar *accounts* nil)
(push admin *accounts*)
(dolist (account *accounts*)
(format t "~{ ~a : ~a ~}~%" account)
(if (and (member "sweatshirt" account) (member "Daemons0!" account))
(progn
(format t "Fact.~%"))))

8
pe1.lisp Normal file
View File

@ -0,0 +1,8 @@
(defvar *sum* 0)
(loop for x from 1 to 999 do
(if (or (zerop(mod x 3)) (zerop (mod x 5)))
(progn
(setq *sum* (+ *sum* x)))))
(format t "~d ~%" *sum*)

10
pe3.lisp Normal file
View File

@ -0,0 +1,10 @@
(defvar div 2)
(defvar num 317584931803)
(loop
(if (zerop(mod num div))
(progn
(setq num (/ num div))
(setq div (- div 1)))
(setq div (+ div 1)))
(when (< num 1) (return div)))

13
tes.lisp Normal file
View File

@ -0,0 +1,13 @@
(setq *print-case* :downcase)
(format t "Username: ")
(defvar *username* (read))
(format t "Password: ")
(defvar *password* (read))
(defparameter tes1 'sweatshirt)
(defparameter tes2 'Daemons0!)
(terpri)
(format t "~a~%" (equalp tes1 *username*))

39
text-gamev1.lisp Normal file
View File

@ -0,0 +1,39 @@
(setq *print-case* :downcase)
(defvar *username* nil)
(defvar *password* nil)
(defvar *new-username* nil)
(defvar *new-password* nil)
(defparameter *accounts* nil)
(defvar inc 0)
(loop (setq cm (read))
(if (eq cm 'q)
(return))
(if (eq cm 'create)
(progn
(format t "New Username: ")
(setq *new-username* (read))
(format t "New password: ")
(setq *new-password* (read))
(push (list :username *new-username* :password *new-password*) *accounts*)
))
(if (eq cm 'login)
(progn
(format t "Username: ")
(setq *username* (read))
(format t "Password: ")
(setq *password* (read))
(dolist (acc *accounts*)
(defparameter check1 (getf (nth inc *accounts*) :username))
(defparameter check2 (getf (nth inc *accounts*) :password))
(if (and (equalp *username* check1) (equalp *password* check2))
(progn
(format t "Thank you for logging in, ~a~%" *username*)
(format t "~a is now ready to play!~%" *username*))
(format t "please type <create> to create an account. Otherwise, enter some valid information."))))))

116
webserver.lisp Normal file
View File

@ -0,0 +1,116 @@
(defparameter *server* (make-instance 'tbnl:easy-acceptor
:port 33333
:address "0.0.0.0"))
(defun start ()
(tbnl:start *server*))
(defun stop()
(tbnl:stop *server*))
(defparameter *css*
"body {
background: #f0f2f5;
font-family: monospace;
}
.nav-wrapper {
background-color: blue;
padding: 15px;
}
.form-wrapper {
position: relative;
top: 55px;
padding: 15px 10px;
background-color: #fff;
width: 400px;
border-radius: 5px;
box-shadow: 8px 8px 8px lightgrey;
}
.username {
position: relative;
display: flex;
margin-left: auto;
margin-right: auto;
border: 1px solid lightgrey;
border-radius: 5px;
padding: 15px;
font-size: 1.2rem;
width: 95%;
}
.password {
position: relative;
display: flex;
margin-left: auto;
margin-right: auto;
border: 1px solid lightgrey;
border-radius: 5px;
padding: 15px;
font-size: 1.2rem;
width: 95%;
}
.nav-wrapper a {
margin-left: 15px;
margin-right: 15px;
text-decoration: none;
font-size: 1rem;
color: #fff;
}
.nav-wrapper a:hover {
cursor: pointer;
text-decoration: underline;
}
.title-wrapper {
display: flex;
justify-content: center;
}
.content {
font-size: 1.1rem;
}")
(tbnl:define-easy-handler (main :uri "/")
()
(spinneret:with-html-string
(:html
(:head
(:style
*css*))
(:body
(:div :class "whole-wrapper"
(:div :class "nav-wrapper"
(:a :class "home-link" :href "/"
"Home")
(:a :class "about-link" :href "/about"
"About"))
(:div :class "title-wrapper"
(:h1 :class "title"
"Welcome to my CL server!"))
(:div :class "form-wrapper"
(:form :class "login" :action "/members" :method "POST"
(:input :type "text" :class "username" :name "username" :placeholder "Username")
(:br)(:br)
(:input :type "password" :class "password" :name "password" :placeholder "Password"))))))))
(tbnl:define-easy-handler (about :uri "/about")
()
(spinneret:with-html-string
(:html
(:head
(:style
*css*))
(:body
(:div :class "whole-wrapper"
(:div :class "nav-wrapper"
(:a :class "home-link" :href "/"
"Home")
(:a :class "about-link" :href "/about"
"About"))
(:div :class "content-wrapper"
(:div :clsas "about-title-wrapper"
(:h1 "About this site"))
(:div :class "content-wrapper"
(:p :class "content"
"I am an intermediate programmer who is new-ish to common assoc.lisp
and am loving it so far! So much so that I have decided to practice
making a webserver; though i usually do this with node js, handling
request with response, i decided to do the same with common lisp!
I will be using hunchentoot, spinneret and lass(maybe?) to create
this site; I hope you enjoy :)"))))))))