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 / robots.rb
Created October 21, 2024 09:26
Robots.rb
# frozen_string_literal: true
# Robot name
# When robots come off the factory floor, they have no name.
#
# The first time you boot them up, a random name is generated in the format of two uppercase letters followed by three digits, such as RX837 or BC811.
#
# Every once in a while we need to reset a robot to its factory settings, which means that their name gets wiped. The next time you ask, it will respond with a new random name.
#
# The names must be random: they should not follow a predictable sequence.
@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;