Nano Bottom Page

How to get the bottom of the page To get to the bottom of a page in nano, type: “ctrl + W” and then “ctrl + V”. How to select text (to copy/delete) press “cntrl + 6” you will see “mark set” select the text copy, delete, or do whatever then, press “cntrl + 6” and you will see “mark unset”; this stops the highlighting mode.

October 2, 2023

Nohup: Linux command to run scripts in background

The command nohup python your-script.py & nohup: This stands for “no hang up.” It’s a Unix command that is used to run another command (in this case, python your-script.py) in a way that it continues to run even after you close the terminal or log out of your session. Essentially, it prevents the command from being terminated when you log out. &: The ampersand at the end of the command tells the shell to run the preceding command (in this case, the Python script) in the background....

September 25, 2023

Pickle Files

import pickle Open the file in binary write mode and save the object with open("pickle_filename.pickle", 'wb') as file: pickle.dump(my_list, file) with open("pickle_filename.pickle", 'rb') as file: loaded_object = pickle.load(file)

September 20, 2023

Php Sql Web

Today I learned the following: Create a database on hostgator via PHPMyAdmin Create demo data for SQL table Create PHP code to connect to database Create HTML file to take user input and retrieve data from database Create a subdomain for a single host plan Add a git repo to that subdomain ssh into my host plan, and use git to push updates Writing SQL-Injection Resistant PHP Code Using a non ‘index....

September 16, 2023

Python Command Line Clear

import os os.system('clear') def clear(): os.system('clear') Using the above function, all you need to run is “clear()” (don’t forget to add the open parenthesis!) and bam: you can now clear your view!

September 16, 2023

Huggingface Classification

First make all your imports and define your model and tokenizer: from transformers import AutoModelForSequenceClassification, AutoTokenizer from transformers import RobertaTokenizer import torch import pandas as pd model = AutoModelForSequenceClassification.from_pretrained("bert-base-uncased").to('cuda') tokenizer = RobertaTokenizer.from_pretrained('bert-base-uncased') NOTE: Adding “.to(‘cuda’)” to the model instance is vital if you wish to speed up inference time (trust me, you want to do this) Next, create the actual function to run inference: def classify_text(text): # Tokenize the input text inputs = tokenizer(text, return_tensors='pt')....

September 10, 2023

Sql Server

Please note: many of these tricks are done from the perspective of a mac user. Locating the my.cnf file Please note: the default location where mysql config files are stored for mac users under /usr/local/etc/mysql Instead of /etc/mysql This is where you can change the bind-address = 127.0.0.1 to bind-address = 0.0.0.0, to allow all access, including from a remote server (important if you’re working from a remote server). Accessing mysql from the cli mysql -u root -p Restarting the sql server This is helpful especially after you’ve made some changes to the users and/or configuration....

August 14, 2023

Hugo Static Site Generator

TL;DR This is where I pull put down what I learn as I become better at Hugo Static Site Generator Zero to Hero: Create a fully-functional site in 12 steps Step 0 Brew install hugo if you have not already done so. ALSO, if you run into any issues when running “hugo server”, or issues when deploying from any web host, consider upgrading your hugo with the following: brew upgrade hugo Step 1 Create a new project with the following command:...

August 11, 2023

Aws Ec2 Port Forwarding

Steps 1. Pip install jupyter notebook (or make sure you have the right environment activated) 2. Open a new terminal window, cd where you have your .pem key 3. Then, on that new window, enter command: a. ssh -i ~/folder/folder/folder/aws/certs/pnnl_alejandro_michel.pem -L 8000:localhost:8888 ec2-user@url 4. Go on browser and enter “localhost:8000” 5. Done a. Side notes: i. Additional login steps may be required, but they’re easy lifts ii. ssh -i ~/folder/folder/folder/aws/certs/pnnl_alejandro_michel.pem ec2-user@url iii....

July 31, 2023

Using GPT for Automatic Database Querying and Code Execution

Introduction This post will show how to prompt GPT (or any language model) to answer a natural language query. Specifically: Take a human-written question write query statements to parse data tables based on human question return final result from database as answer to user’s question This code can be found in this repo. The Code Without further adu, below is the code itself. import openai import os openai.api_key = os.environ["OPENAI_API_KEY"] import time query = "Feel like eating some good chinese food tonight....

July 25, 2023