Skip to content

Instantly share code, notes, and snippets.

View jbxamora's full-sized avatar
🥁
loading . . .

jbxamora

🥁
loading . . .
View GitHub Profile
@jbxamora
jbxamora / urlregex.md
Last active February 28, 2023 05:28
URL REGEX

URL Regex

This regular expression is designed to match a wide range of URLs, including those that use different protocols (such as https, http, and ftp) and those that include an IP address or domain name.

/^(http:\/\/www\.|https:\/\/www\.|http:\/\/|https:\/\/)?[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}(:[0-9]{1,5})?(\/.*)?$/;

Table of Contents

@jbxamora
jbxamora / chatbot.md
Last active February 28, 2023 05:04
Test your own personal chatbot.

Chatbot

This Python script uses OpenAI's GPT-3 language model to create an advanced chatbot that can assist users by answering questions, providing helpful information, or completing tasks based on user input. The script prompts the user for input and then uses the OpenAI API to get a response from the GPT-3 model. The script then prints the chatbot response and updates the conversation history with the user's input and the chatbot's response.

To use the script, you will need to set your OpenAI API key and model engine in the script. You can then run the script in a terminal or command prompt by typing python chatbot.py and pressing Enter.

The script uses the openai Python package to access the OpenAI API and the input() function to prompt the user for input. The script defines a get_response() function that takes the conversation history and user input as arguments, replaces the placeholders in the chatbot prompt with the conversation history and user input, and then uses the OpenAI API to get

@jbxamora
jbxamora / Mini-Algorithms.md
Last active March 30, 2023 08:11
Mini Algorithms

Mini-Algorithms

This gist showcases two simple yet effective algorithms: the Sieve of Eratosthenes for finding prime numbers and Dijkstra's algorithm for finding the shortest path in a graph.

Sieve of Eratosthenes

The Sieve of Eratosthenes is an ancient algorithm for finding all prime numbers up to a given limit. It's named after the ancient Greek mathematician Eratosthenes, who introduced this method around 240 BC. The algorithm works by iteratively marking the multiples of each prime number, starting from 2.

The time complexity of the Sieve of Eratosthenes is O(n log log n) for finding all prime numbers up to n, which makes it one of the most efficient methods for finding small to moderately large prime numbers.

@jbxamora
jbxamora / neuronimg.md
Created March 30, 2023 21:44
TensorFlow Img Classification

TensorFlow Image Classification

This is an example neural network implemented in Python using TensorFlow library. The purpose of this network is to classify images of hand-written digits from the MNIST dataset.

Architecture

The network has three hidden layers, each with 128 neurons and ReLU activation function. The output layer has 10 neurons, corresponding to the 10 classes (digits) in the dataset, and uses softmax activation function to output class probabilities.

Code

Here's the code for the neural network: