Skip to content

Instantly share code, notes, and snippets.

View calleia's full-sized avatar

Fellipe Calleia calleia

View GitHub Profile
@calleia
calleia / time-log.sh
Created May 15, 2024 17:25
Shell script that appends the current date and time along with a custom message to a log file.
#!/bin/bash
# Set the log file path
log_file="/path/to/time.log"
# Get the current date and time
current_date_time=$(date +"%Y-%m-%d %H:%M:%S")
# Message to print
message="This is a log message."
@calleia
calleia / loop.sh
Last active April 30, 2024 22:14
Shell script that runs a command in a loop for a specified number of times.
#!/bin/bash
# Check if correct number of arguments are provided
if [ $# -ne 2 ]; then
echo "Usage: $0 <number_of_iterations> <command_to_be_executed>"
exit 1
fi
# Set the number of iterations
iterations=$1
@calleia
calleia / generate-ethereum-wallet-with-mnemonic.py
Created June 7, 2023 22:33
Create a new Ethereum wallet and print the wallet address, private key and seed phrase.
from eth_account import Account
Account.enable_unaudited_hdwallet_features()
account, mnemonic = Account.create_with_mnemonic()
print(f'{account.address},{account.key.hex()},{mnemonic}')
@calleia
calleia / generate-ethereum-wallet.py
Created June 7, 2023 22:28
Create a new Ethereum wallet and print the wallet address and private key.
from eth_account import Account
account = Account.create()
print(f'{account.address},{account.key.hex()}')
@calleia
calleia / create-png.py
Created May 28, 2023 16:23
Create a PNG image and set each pixel with a random color.
from PIL import Image
import random
# Set the size of the image
width, height = 32, 32
# Create a new image with the specified size
img = Image.new('RGB', (width, height))
# Get access to the pixels of the image
@calleia
calleia / color-generator.py
Created May 26, 2023 23:22
Create a new text file containing all colors from the 24-bit RGB color space (#000000 to #FFFFFF).
total_colors = 256 ** 3 # R * G * B
f = open('colors.txt', 'w', encoding="utf-8")
for x in range(total_colors):
color_hex = '%06X' % x
f.write(color_hex + '\n')
f.close()
@calleia
calleia / hash.js
Created October 23, 2022 17:51
SHA-256 hash function in Javascript.
async function digestMessage(message) {
const encoder = new TextEncoder();
const data = encoder.encode(message);
const hashBuffer = await crypto.subtle.digest('SHA-256', data);
const hashArray = Array.from(new Uint8Array(hashBuffer));
const hashHex = hashArray.map((b) => b.toString(16).padStart(2, '0')).join('');
return hashHex;
}
@calleia
calleia / cube.stl
Created October 3, 2022 16:26
A cube in ASCII STL format
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@calleia
calleia / config.json
Last active May 14, 2021 19:08
Configuration file
{
"version": "0.1.0"
}
@calleia
calleia / getDegrees.swift
Created July 29, 2019 13:45
Get angle of point in degrees (Swift)
func getDegrees(point: CGPoint, origin: CGPoint = CGPoint.zero) -> CGFloat {
let deltaX = point.x - origin.x
let deltaY = point.y - origin.y
let radians = atan2(deltaY, deltaX)
let degrees = radians * (180.0 / CGFloat.pi)
guard degrees < 0 else {
return degrees
}