Skip to content

Instantly share code, notes, and snippets.

View juan-reynoso's full-sized avatar
🏠
Working from home

Juan Reynoso juan-reynoso

🏠
Working from home
View GitHub Profile
@juan-reynoso
juan-reynoso / arrow-functions.js
Created October 4, 2021 19:44
Traditional functions and arrow functions
// Traditional functions
function mySum(x, y){
return x + y;
}
function myHello(){
return "Hello.";
}
function myMagicFunction(){
let x = 10;
return x + 5;
@juan-reynoso
juan-reynoso / syntax-highlighting-for-the-web.html
Last active March 21, 2022 20:56
Example: Syntax highlighting for the Web
<!DOCTYPE html>
<html lang="es">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Syntax highlighting for the Web</title>
<!-- highlight-->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.5.0/styles/rainbow.min.css">
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css">
@juan-reynoso
juan-reynoso / JavaScript Objects.js
Created October 12, 2021 17:10
Creating a JavaScript Objects
/* Creates a single object, using an object literal.
* An object literal is a list of name:value pairs
(like age:36) inside curly braces {}.
*/
let myObjectPerson = { name: 'Juan', age: 36, sayHello: function (){
console.log("Hello, I am " + this.name + " and I am " +
this.age + " years old.");}
};
@juan-reynoso
juan-reynoso / Object-Oriented-programming-example.py
Created October 13, 2021 15:54
Python Object-Oriented programming example.
# Python Object-Oriented programming
# Define a class called Dog
# Python class names are written in CapitalizedWords notation by convention.
class Dog:
# define a method called __init__ it is a special init method.
# "__init__" is a reseved method in python classes. It is known as a constructor in object oriented concepts.
# This method called when an object is created from the class and it allow the class to initialize the attributes of a class.
def __init__ (self, name, age):
# self represents the instance of the class. By using the "self" keyword. We can access the attibutes and methods of the
@juan-reynoso
juan-reynoso / Lisp files.lisp
Created October 28, 2021 22:51
A file handling example
(defparameter *line* nil "This is a global variable")
;;; an example
(with-open-file (file "/tmp/myfile.txt" :direction :input)
(loop
;; gets a line from the file
(setf *line* (read-line file nil))
(if *line*
;; print the lines stored in the text file
(format t "~% ~a ~%" *line*)
@juan-reynoso
juan-reynoso / copy-file.lisp
Created October 29, 2021 22:05
Creating streams on files
(defun copy-a-file (origin-path new-path)
"Copy a file"
(let ((value-from-read-byte nil))
;; create a stream which reads a file
(with-open-file (origin-file origin-path :direction :input
:element-type 'unsigned-byte)
;; create a stream which write into a file
(with-open-file (new-file new-path :direction :output
:element-type 'unsigned-byte
:if-exists :supersede)
@juan-reynoso
juan-reynoso / generic-functions.lisp
Created December 29, 2021 18:56
Generic functions
;;; A generic function specifies only the interface.
;;; It performs a high-level operation.
;;; Generic functions are functions that behave differently
;;; depending on the type and identity of the arguments.
(defgeneric say-type-of-object (x)
(:documentation "It displays the type of an object."))
;;; The implementation of a generic function does not exist in one place; it
;;; is distributed across a set of methods.
(in-package :postmodern)
(defvar *db-parameters* '("my_database" "lisp_user" "your-secret" "localhost" :POOLED-P T)
"Information about the connection of database.")
(defparameter *my-fruit* nil
"This var will has an object of fruits.")
;;; Define the macro to connect to the postgresql server
(defmacro with-database (&body query)
;;;; The Standard Method Combination
(defclass book ()
((name :accessor book-name
:initarg :book-name)))
;;; Create an object
(defparameter *book* (make-instance 'book
:book-name "The Art of the Metaobject Protocol"))

How to install and configure your IDE for Common Lisp

SBCL

SBCL is a high performance Common Lisp compiler.

http://www.sbcl.org/

SBCL installation as super user (root)

You need to run the commands as super user (root)

Download