Skip to content

Instantly share code, notes, and snippets.

View AdrianAcala's full-sized avatar

Adrian-Ryan Acala AdrianAcala

  • Bakersfield, CA
View GitHub Profile
// ==UserScript==
// @name Auto Click Through AWS SAML
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Cause laziness runs the world.
// @author aacala
// @match https://signin.aws.amazon.com/saml
// @grant none
// @require http://code.jquery.com/jquery-3.3.1.min.js
// ==/UserScript==
@AdrianAcala
AdrianAcala / pool.py
Created February 26, 2020 18:40
Python multithreading pool example
import multiprocessing
def func(x):
print(x*x)
num_of_workers = multiprocessing.cpu_count()
pool = multiprocessing.Pool(num_of_workers)
for i in range(1,10):
pool.apply_async(func, args=(i,))
@AdrianAcala
AdrianAcala / execute_sql.sh
Last active February 28, 2020 01:08
Command to execute the contents of a file into a MySQL database
mysql -h$MYSQL_HOSTNAME -u$MYSQL_USERNAME -p$MYSQL_PASSWORD < file.sql
@AdrianAcala
AdrianAcala / main.go
Last active January 28, 2022 19:55
How often will a double flop be the same rank
package main
import (
"fmt"
"math/rand"
"sort"
"time"
)
func createDeck() *[52]int {
@AdrianAcala
AdrianAcala / mkcd.sh
Created December 15, 2022 21:25
Bash function that takes a directory name and creates it then enters that folder
function mkcd() {
# Check if the directory already exists
if [ -d "$1" ]; then
# If the directory already exists, print an error message
printf "Error: directory '%s' already exists\n" "$1"
else
# If the directory does not already exist, create it
mkdir "$1"
# Check if the directory was successfully created
@AdrianAcala
AdrianAcala / test_cert.py
Last active January 10, 2023 18:02
Tests a certificate to see whether the certificate matches the domain name
#!/usr/bin/env python3
# Create a script that will check if the certificate matches the hostname of the server
# and if the certificate is valid
import socket
import ssl
import time
def check_dns_record(hostname, port):
@AdrianAcala
AdrianAcala / merge_files.py
Last active January 13, 2023 22:31
Merges log files together but keeps lines with a tab together with the previous line
import argparse
import heapq
def merge_log_files(input_files, output_file):
with open(output_file, 'w') as out_file:
for line in heapq.merge(*(open(f,'r') for f in input_files)):
current_block = []
if line.startswith("\t"):
current_block.append(line)
@AdrianAcala
AdrianAcala / install-axolotol.sh
Created January 17, 2024 14:23
Installs Axolotol on Paperspace
#!/bin/bash
wget https://repo.anaconda.com/archive/Anaconda3-2023.09-0-Linux-x86_64.sh -P /tmp
bash /tmp/Anaconda3-2023.09-0-Linux-x86_64.sh -b
/root/anaconda3/bin/conda init --all
/root/anaconda3/bin/conda update -n base -y -c defaults conda
source /root/.bashrc
/root/anaconda3/bin/conda install -y python=3.10
/root/anaconda3/bin/conda install -y pytorch torchvision torchaudio pytorch-cuda=12.1 -c pytorch -c nvidia
@AdrianAcala
AdrianAcala / gist:2962c555ab3ff0066f9a095673c88a7b
Created April 7, 2024 05:25
Removes all IPs from known_hosts except IPs that start with 192 or have an FQDN
while IFS= read -r line; do
if [[ $line =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+[[:space:]] ]]; then
ip=$(echo "$line" | awk '{print $1}')
if [[ $ip =~ ^192\. ]]; then
echo "$line"
fi
else
echo "$line"
fi
done < ~/.ssh/known_hosts > ~/.ssh/known_hosts.new && mv ~/.ssh/known_hosts.new ~/.ssh/known_hosts