Skip to content

Instantly share code, notes, and snippets.

View lucablackwell's full-sized avatar
🌸
Did you know you have rights? The constitution says you do, and so do I!

Luca Blackwell lucablackwell

🌸
Did you know you have rights? The constitution says you do, and so do I!
View GitHub Profile
@lucablackwell
lucablackwell / rps_final_file.php
Last active November 29, 2022 10:51
rock paper scissors with various options, file functionality
<?php
$choices = array('r', 'p', 's');
$start = microtime(true);
$wins = 0;
$draws = 0;
$losses = 0;
$prandom = true;
// Get input
@lucablackwell
lucablackwell / docker-switch.sh
Last active November 29, 2022 10:39
script that quickly switches between docker instances, or starts the chosen one if nothing is running
#!/bin/bash
# Swaps local docker instances
# (I recommend making an alias to call the script)
# Directory names will need changing for your needs!
function start () {
# Change to the chosen directory
cd ~/GIT/$1
# Start the chosen containers
@lucablackwell
lucablackwell / string_gen.php
Last active November 29, 2022 10:32
generates a string randomly from given characters, extended file functionality
<?php
# Colour functions
function blue($text) {
return "\e[;36m$text\e[0m";
}
function blue_bold($text) {
return "\e[1;36m$text\e[0m";
}
@lucablackwell
lucablackwell / password-gen.php
Last active November 29, 2022 10:16
php password generator, one-liner or interactive - substitutes letters for numbers, makes sure there are caps and punctuation
<?php
# generates password
# Colours
function blue($text) {
return "\e[;36m$text\e[0m";
}
function blue_bold($text) {
return "\e[1;36m$text\e[0m";
https://gist.github.com/lucablackwell/44abc998adfa8d67a08fa99bec2dfcca
https://gist.github.com/lucablackwell/44abc998adfa8d67a08fa99bec2dfcca
https://gist.github.com/lucablackwell/44abc998adfa8d67a08fa99bec2dfcca
https://gist.github.com/lucablackwell/44abc998adfa8d67a08fa99bec2dfcca
https://gist.github.com/lucablackwell/44abc998adfa8d67a08fa99bec2dfcca
https://gist.github.com/lucablackwell/44abc998adfa8d67a08fa99bec2dfcca
https://gist.github.com/lucablackwell/44abc998adfa8d67a08fa99bec2dfcca
https://gist.github.com/lucablackwell/44abc998adfa8d67a08fa99bec2dfcca
https://gist.github.com/lucablackwell/44abc998adfa8d67a08fa99bec2dfcca
https://gist.github.com/lucablackwell/44abc998adfa8d67a08fa99bec2dfcca
@lucablackwell
lucablackwell / text-template.php
Last active November 29, 2022 10:09
A template for interactive CLI text adventures
<?php
# Colours
function cyan($text) {
return "\e[0;36m$text\e[0m";
}
function cyan_bold($text) {
return "\e[1;36m$text\e[0m";
}
<?php
# Colours
function green($text) {
return "\e[0;32m$text\e[0m";
}
function yellow($text) {
return "\e[0;33m$text\e[0m";
}
<?php
# Guess the number, input range, returns higher or lower
# get the number of games
# loop for each game
# get the range
# assign random number from range
# loop while user guesses
# if (sanitised) guess is too high or too low, say
<?php
# Colours
function cyan($text) {
return "\e[0;36m$text\e[0m";
}
function cyan_bold($text) {
return "\e[1;36m$text\e[0m";
}
<?php
function sanitise_num($limit, $default) {
$sanitised = false;
$input = readline('> ');
while (!$sanitised) {
# If there are letters
if (preg_match('/[a-z]/', $input)) {
echo "No letters.\n";
$input = readline('> ');