Skip to content

Instantly share code, notes, and snippets.

View Andrej123456789's full-sized avatar
:electron:
?

Andrej Bartulin Andrej123456789

:electron:
?
View GitHub Profile
@Andrej123456789
Andrej123456789 / number.c
Created June 23, 2024 15:09
DOS Showdown game 1
#include <stdio.h>
#include <time.h>
#include <stdlib.h>
int main()
{
char input[3];
int input_number;
int generated_number;
;
; _e820 -> call _do_e820 function from assembly to not get random garbage
; Thanks to Nanobyte for help
;
global _e820
_e820:
; make new call frame
push bp ; save old call frame
mov bp, sp ; initialize new call frame
; use the INT 0x15, eax= 0xE820 BIOS function to get a memory map
; note: initially di is 0, be sure to set it to a value so that the BIOS code will not be overwritten.
; The consequence of overwriting the BIOS code will lead to problems like getting stuck in `int 0x15`
; inputs: es:di -> destination buffer for 24 byte entries
; outputs: bp = entry count, trashes all registers except esi
mmap_ent equ 0x8000 ; the number of entries will be stored at 0x8000
global _do_e820
_do_e820:
mov di, 0x8004 ; Set di to 0x8004. Otherwise this code will get stuck in `int 0x15` after some entries are fetched
xor ebx, ebx ; ebx must be 0 to start
#include <stdint.h>
#include <stddef.h>
#include <stdbool.h>
#include "limine.h"
#include "kernel/kernel.h"
// The Limine requests can be placed anywhere, but it is important that
// the compiler does not optimise them away, so, usually, they should
import { Configuration, OpenAIApi } from "openai";
import { writeFileSync } from "fs";
async function Generate(prompt) {
const configuration = new Configuration({
apiKey: "your api key",
});
const openai = new OpenAIApi(configuration);
const result = await openai.createImage({
#![allow(unused_must_use)]
use clearscreen;
use crossterm::{style, QueueableCommand};
use std::io::{stdin, stdout, Stdout, Write};
fn quiz(stdout: &mut Stdout) {
let questions: [String; 11] = [
String::from("Što je štednja [A - čuvanje materijalnih dobara od potrošnje u određenoj situaciji; B - neumjerena potrošnja novca; C - skakanje iz zrakoplova s instruktorom]: "), // A
use std::time::Instant;
use rand::thread_rng;
use rand::seq::SliceRandom;
fn create_shuffled_numbers(num_prisoners: i64) -> Vec<i64> {
let mut a: Vec<i64> = Vec::new();
let mut i = 0;
while i < num_prisoners {
/* Just random math problem written in LaTex */
\begin{quote}
\huge
{
\[\frac
{
\frac
{
\frac
#include <stdio.h>
int main()
{
int num;
printf("Enter a number: \n");
scanf("%d", &num);
if (num >= 0)