Skip to content

Instantly share code, notes, and snippets.

View Beyarz's full-sized avatar
💎
Searching for Ruby gems

Beyar Beyarz

💎
Searching for Ruby gems
  • Sweden
  • 09:18 (UTC +02:00)
View GitHub Profile
@Beyarz
Beyarz / README.md
Created May 10, 2025 14:36
Chat with a friend through LAN. script I wrote 8 years ago. Adding it here for memory.

Talkwithme

One script, two purposes.

Setup guide (server)

  • Run python2 talkwithme.py
  • Press 1 then hit enter
  • Enter your private ip address (it will be printed out)
  • Enter any port number (that is not in use)
  • Enter the clients ip address
  • Enter the clients port number
@Beyarz
Beyarz / howbout.rb
Created December 24, 2024 17:19
Create plans on howbout.app
# frozen_string_literal: true
require 'net/http'
require 'uri'
require 'json'
require 'securerandom'
MY_API_KEY = "..."
BEARER = "..."
BAGGAGE = "..."
@Beyarz
Beyarz / power_set.rb
Last active January 1, 2025 18:07
Calculate power set from an array
arr = [1, 2, 3]
# => [1, 2, 3]
def power_set(arr)
result = [[]]
arr.each do |element|
result += result.map do |num|
num + [element]
end
@Beyarz
Beyarz / bulk_rename.rb
Created August 8, 2024 21:13
Rename every folder in a directory
# frozen_string_literal: true
# Put me in a folder where you want to bulk rename every folder
# In this case, this script will rename every folder from "Photos from YEAR" to "YEAR" only
# Run: ruby bulk_rename.rb
folders = Dir.entries('.').reject { ['.', '..'].include? _1 }
folders.each do |folder|
File.rename(File.join(Dir.pwd, folder), File.join(Dir.pwd, folder.delete_prefix("Photos from ")))
end
@Beyarz
Beyarz / flatten.rb
Last active August 9, 2024 17:57
Flatten a directory structure and its hierarchy. This script moves every file in a subfolder to its parent and then delete the subfolder
# frozen_string_literal: true
# Put me in a folder where you want to get rid of all the subfolders
# Run: ruby flatten.rb
def move_and_delete(dir)
puts "Cleaning \"#{dir}\""
Dir.foreach(dir) do |file|
next if ['.', '..'].include?(file)
@Beyarz
Beyarz / collision.c
Created June 8, 2024 12:42
Check collision between a circle and a rectangle
#include <math.h>
typedef float f32;
typedef struct Vector2
{
f32 x, y;
} Vector2;
typedef SDL_FRect RectangleF;
typedef struct Circle
@Beyarz
Beyarz / common.h
Created June 8, 2024 12:37
Shorter typdefs
typedef uint8_t u8;
typedef uint16_t u16;
typedef uint32_t u32;
typedef uint64_t u64;
typedef size_t umax;
typedef int8_t s8;
typedef int16_t s16;
typedef int32_t s32;
@Beyarz
Beyarz / README.md
Last active November 8, 2024 21:03
Comprehensive guide to get working environment with MRuby

Getting started

Compile on Windows

  1. Install msys2 (because we need mingw64, gcc and libws2_32.a)
  2. Open msys2 or mingw64 and run pacman -S mingw64/mingw-w64-x86_64-mruby
  3. Get MRuby and extract the folder
  4. Run make inside the folder mruby-3.3.0, there will be a new folder called /build after the compilation, we need the file at /build/host/lib/libmruby.a
  5. Compile using the following command gcc main.c -I"mruby-3.3.0/include" "mruby-3.3.0/build/host/lib/libmruby.a" "C:\msys64\mingw64\lib\libws2_32.a" -lm -o main or substitue "C:\msys64\mingw64\lib\libws2_32.a" with -lws2_32
  6. Run the compiled binary main.exe
@Beyarz
Beyarz / windows_subsystem_cmd.md
Last active March 28, 2024 13:01
Windows unix commands in CMD

Run unix stuff in cmd

Run: choco install msys

Symlink directory (some project assume its in C:\msys64): MKLINK /D "C:\msys64" "C:\tools\msys64"

Add the following path C:\msys64\usr\bin to your PATH environment variable

Now you shoule be able to run pacman -Q, choco list | sed s/msys2/test/g, help | grep disk

We can make this file beautiful and searchable if this error is corrected: It looks like row 2 should actually have 1 column, instead of 7 in line 1.
2023;Jan;Feb;Mars;April;Maj;Juni;Juli;Aug;Sep;Okt;Nov;Dec
Södertörn;469,25;469,25;424,5;424,5;439;439;435;435;460;460;457,5;457,5
Stockholm;497,5;497,5;425;425;460;460;465;465;529;529;485;485
Nacka;-;-;520;520;449,75;449,75;455,25;455,25;462,5;462,5;470,25;470,25
Solna;535;535;437,5;437,5;491,75;491,75;-;-;503,5;503,5;470;470
Attunda;503;503;417,5;417,5;460,5;460,5;431,25;431,25;475;475;453,75;453,75
2022;Jan;Feb;Mars;April;Maj;Juni;Juli;Aug;Sep;Okt;Nov;Dec
Södertörn;452,5;452,5;423,75;423,75;436;436;487,75;487,75;441,25;441,25;454,75;454,75
Stockholm;498,5;498,5;482,5;482,5;470;470;453;453;477,5;477,5;475;475
Nacka;463,5;463,5;426;426;426,5;426,5;-;-;452,5;452,5;440;440