Skip to content

Instantly share code, notes, and snippets.

View Niall47's full-sized avatar
🐢
Doing a learn about codes and that

Niall47

🐢
Doing a learn about codes and that
View GitHub Profile
@Niall47
Niall47 / pal_scraper.rb
Created April 7, 2024 16:11
capture all the combinations of pals for breeding
# frozen_string_literal: true
require 'capybara'
require 'capybara/dsl'
require 'selenium/webdriver'
Capybara.register_driver :firefox do |app|
Capybara::Selenium::Driver.new(app, browser: :firefox)
end
Capybara.default_driver = :firefox
@Niall47
Niall47 / env.rb
Created November 9, 2023 07:50
Ruby Cucumber ParameterTypes example
class CustomerScenario
def initialize(scenario)
@scenario = scenario
end
end
ParameterType(
name: 'customer_scenario',
regexp: /passed|failed|banned/,
@Niall47
Niall47 / find_binary.sh
Created October 18, 2023 08:03
Find binary script. Runs -v on each instance it finds.
#!/bin/bash
if [ $# -eq 0 ]; then
echo "Usage: $0 <executable_name>"
exit 1
fi
executable="$1"
IFS=':' read -ra path_dirs <<< "$PATH"
@Niall47
Niall47 / sym_link_schematics_folder.sh
Last active June 22, 2023 14:19
MultiMC - Share schematics folder (linux)
@Niall47
Niall47 / outdated_gems.sh
Last active February 8, 2023 10:04
search through functional test packs and output any gem versions that could be updated. Thanks ChatGPT
#!/bin/bash
# Search for directories with name 'functional-tests' in current directory
for directory in $(find . -type d -name 'functional-tests'); do
# Check if a Gemfile exists in the directory
if [ -e "$directory/Gemfile" ]; then
# Output which directory is being checked
echo -e "\033[0;34mChecking gems in directory:\033[0m $directory"
# Change into the directory and run the bundler outdated command
# frozen_string_literal: true
module Tictactoe
# Player records the symbol being used
class Player
attr_reader :symbol
def initialize(symbol)
@symbol = symbol
end
We couldn’t find that file to show.
@Niall47
Niall47 / collatz.rb
Last active December 17, 2021 09:01
=begin
Collatz Conjecture
Hint: recursion!
The Collatz Conjecture or 3x+1 problem can be summarized as follows:
Take any positive integer n. If n is even, divide n by 2 to get n / 2. If n is odd, multiply n by 3 and add 1 to get 3n + 1. Repeat the process indefinitely. The conjecture states that no matter which number you start with, you will always reach 1 eventually.
Given a number n, return the number of steps required to reach 1.
Example:
Starting with n = 12, the steps would be as follows:
12
6
@Niall47
Niall47 / slider.html
Created December 9, 2021 09:33
Power sliders for Raspberry Pi PWM pins. runs on port 8081, give it the Raspberry Pi's IP if you're connecting remotely
<!DOCTYPE html>
<html>
<style>
.rangeslider{
width: 50%;
}
.myslider {
-webkit-appearance: none;
=begin
Run length encodingRun-length encoding (RLE) is a simple form of data compression, where runs (consecutive data elements) are replaced by just one data value and count.
For example we can represent the original 53 characters with only 13.
"WWWWWWWWWWWWBWWWWWWWWWWWWBBBWWWWWWWWWWWWWWWWWWWWWWWWB" -> "12WB12W3B24WB"
RLE allows the original data to be perfectly reconstructed from the compressed data, which makes it a lossless data compression."AABCCCDEEEE" -> "2AB3CD4E" -> "AABCCCDEEEE"
For simplicity, you can assume that the unencoded string will only contain the letters A through Z (either lower or upper case) and whitespace.
This way data to be encoded will never contain any numbers and numbers inside data to be decoded always represent the count for the following character.
=end
# Usage example