Skip to content

Instantly share code, notes, and snippets.

View compscitwilight's full-sized avatar

Rust compscitwilight

View GitHub Profile
// my very first Rust program
// an HTTP server which nobody should *ever* use
use std::io::*;
use std::path::Path;
use std::thread;
use std::fs;
use std::env;
use std::str;
use std::net::{TcpListener, TcpStream};
@compscitwilight
compscitwilight / wapper.py
Last active February 12, 2024 18:21
Python script to calculate the total wattage of a power supply in a given amount of time, and also calculate for the price/KWh in a given time period.
psu_watts = int(input("Power supply wattage (w): "))
price_per_wh = float(input("Price per kilowatt hour (cents): "))
days = int(input("Days: "))
total_wattage = psu_watts * (days * 24)
total_price = ((total_wattage / 1000) * price_per_wh) / 100
print()
print("Total wattage: " + str(total_wattage))
print("Total price for " + str(price_per_wh) + "c/KWh: $" + str(total_price))
# !/bin/bash
# This shell script automates the setup process of creating a barebones Electron project
# w/ TypeSCript and TSC compiler scripts.
echo "= Instantializing NPM project... =";
npm init -y
npm i electron
npm i tsc typescript electron-packager --save-dev
@compscitwilight
compscitwilight / Ponies.sh
Created January 15, 2023 17:46
A bash script that shows a certain pony using ponysay.
# written by github:devrusty
# January, 15, 2023
PONY=twilight;
MSG="close this window for more PONY";
COUNT=10;
PONIES=("Twilight" "Applejack" "Pinkie" "Fluttershy" "Rarity" "Rainbow Dash" "Celestia" "Luna" "Cadance" "Flurryheart");
function createPonyWindow {
xterm -bg black -hold -e ponysay -f $PONY $MSG;
}
@compscitwilight
compscitwilight / progressBar.ts
Created September 5, 2022 03:10
A function that generates a progress bar using emojis.
const max = 10
function CreateProgressBar(progress: number) {
if (progress > max) {
console.log(`Progress bar is out of range of ${max}`)
return
}
const progressBar = `${"🟩".repeat(progress)}${"⬛".repeat(max - progress)}`
return progressBar
}
@compscitwilight
compscitwilight / BuildClient.lua
Created September 2, 2022 20:21
Client script for a Roblox build mode system
local UserInputService = game:GetService("UserInputService")
local RunService = game:GetService("RunService")
local Players = game:GetService("Players")
local Building = false
local Mouse = Players.LocalPlayer:GetMouse()
local Brick = script.Part
local function RoundVector3(vector: Vector3)
return Vector3.new(
@compscitwilight
compscitwilight / seed.lua
Created August 31, 2022 05:52
weird terrain generator
local gen = 1000
function generate(i)
local num = math.random(0, i)
local part = Instance.new("Part")
part.BrickColor = BrickColor.random()
part.Anchored = true
part.Parent = workspace
part.Position = Vector3.new(num * 2, 1, num * 3) * math.random(0, 200)