Skip to content

Instantly share code, notes, and snippets.

View mezerotm's full-sized avatar
🪙
0x4EEB2D6Ec9cd842a13ab24c013b7a7A66F6AC2B4

Carlos Rincon mezerotm

🪙
0x4EEB2D6Ec9cd842a13ab24c013b7a7A66F6AC2B4
View GitHub Profile
@mezerotm
mezerotm / stateMachineTransitionActions.js
Last active April 15, 2023 14:54
In this implementation, the state machine takes an object states that defines the possible states and actions for each input. Each state is a nested object with keys representing the inputs that can trigger a transition to another state. The value of each input key is the name of the destination state, or null if the input should be ignored. The…
class StateMachine {
constructor(states) {
this.states = states;
this.currentState = null;
}
transition(input) {
const nextState = this.states[this.currentState][input];
if (nextState) {
this.currentState = nextState;
@mezerotm
mezerotm / stateMachineTransitionActions.js
Last active April 15, 2023 14:54
This code defines a state machine with four states: InitialState, State1, State2, and State3. Each state has a set of possible transitions based on the input received. The code also defines a set of actions that can be executed based on the input received. The `nextState` function takes an input, executes the appropriate action, and transitions …
const stateMachine = (inputs) => {
let currentState = "InitialState";
const actions = {
Action1: () => {
// action code for Action1
console.log("Action1 executed");
},
Action2: () => {
// action code for Action2
@mezerotm
mezerotm / gather-hardware-info.sh
Created January 6, 2023 16:35
SCSI devices, and block devices. It stores the information in a temporary file and uploads the file to termbin.com. The URL of the uploaded file is then printed to the terminal.
#!/bin/bash
# Check if the script has sudo privileges
if [ "$(id -u)" -ne 0 ]; then
# The script does not have sudo privileges
echo "This script requires sudo privileges to run."
echo "Please re-run the script with sudo."
exit 1
fi
@mezerotm
mezerotm / unixHelpers.js
Last active March 25, 2022 23:13
Some common operations I perform with Unix time
const SECONDS_IN_A_DAY = 86400
let sts = 1629072000
let ets = 0
const unixMidnight = time => {
return time - (time % SECONDS_IN_A_DAY)
}
const addDay = time => {
@mezerotm
mezerotm / Calculator.js
Created July 23, 2021 03:32
Command Design pattern using classes in javascript
class Command {
constructor(execute, undo, value) {
this.execute = execute
this.undo = undo
this.value = value
}
}
class Calculator {
constructor() {
@mezerotm
mezerotm / pagination-for-loop.js
Created September 29, 2020 04:21
A for loop for pagination
let numbers = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
let page = 2
let limit = 5
for(let i = (page * limit - limit); i < numbers.length && i < (page * limit); i++) {
console.log(numbers[i])
}
#!/bin/bash
script_version=1.0.4
if [ "$miner_type" = "GPU" ]; then
miner_type=true
else
miner_type=false
fi
cat << "EOF"
+-+-+-+-+-+-+-+-+
# #!/bin/env python3.7
from PyInquirer import prompt
import digitalocean
import paramiko
import json
script_version = "1.1.5"
medusa_script = "https://gist.githubusercontent.com/mezerotm/6266bd247a026636d6530b2f94164045/raw/82b457329ff7c18972242520cd74d6738919a5e4/medusa.sh"
#!/bin/bash
script_version=1.0.2
snake_handler_ip_file=snake-handler-ip-list
snake_handler_script=https://gist.githubusercontent.com/mezerotm/1ea45da80f4c160dadd7dd38dbbeeddb/raw/4ec9676194a39993fbed089638e2ce090400dcfe/snake-handler.sh
cat << "EOF"
88 88
88 "" ,d
88 88
#!/bin/bash
script_version=1.0.2
medusa_script=https://gist.githubusercontent.com/mezerotm/6266bd247a026636d6530b2f94164045/raw/57870c6974150d07a0e3553bca66812f292b961e/medusa.sh
if [ -z "$snake_handler_ip_file" ]; then
snake_handler_ip_file=snake-handler-ip-list
fi
cat << "EOF"