Skip to content

Instantly share code, notes, and snippets.

View viruskizz's full-sized avatar
🎮
Relax

viruskizz viruskizz

🎮
Relax
View GitHub Profile
@viruskizz
viruskizz / mini_serv.c
Last active January 6, 2024 15:25
42bangkok - exam-rank06
/*
Thanks to tliangso
to test
1. run `./a.out 8080`
2. use netcat run `nc 127.0.0.1 8080`
*/
#include <errno.h>
#include <string.h>
#include <unistd.h>
#include <netdb.h>
const axios = require("axios");
// Setup
const xkey = ''; // add your credential
const token = ''; // add your credential
const baseUrl = 'https://api.fbw.center/index.php/v4';
const teamId = '';
const headers = {
'x-api-key': xkey,
'Authorization': `Bearer ${token}`,
@viruskizz
viruskizz / microshell.c
Last active September 23, 2023 14:17
42Bangkok Exam Rank04
#include <string.h>
#include <unistd.h>
#include <sys/wait.h>
static void perr(char *s) {
while (*s)
write(2, s++, 1);
}
static int cd(char **argv, int i) {
@viruskizz
viruskizz / 42Bangkok: minishell_testscript
Last active October 24, 2022 17:00
42Bangkok : Minishell interactive test script
Minishell test script
.
.**+**+=:.
*#********+=:..
:+**=:+###***++********+-.
=***###%#%##****++*********+:
-****###%%%%###******+*********+.
.+#***###%%%%%%#%%#****************=.
.++#***%#*#%%%%%#######****************:
@viruskizz
viruskizz / ft_printf.c
Last active November 22, 2022 15:34
42Exam-Rank03-ft_printf
#include <stdarg.h>
#include <unistd.h>
static int ft_put_base(int nb, char *range, int base, int *len)
{
if (nb < 0 && ++(*len))
return (write(1, "-", 1), ft_put_base(-nb, "0123456789", 10, len));
if (nb >= base)
ft_put_base(nb / base, range, base, len);
return (write(1, &range[nb % base], 1), ++(*len));
@viruskizz
viruskizz / get_next_line.c
Created September 29, 2022 03:01
42Exam-Rank03-get_next_line
#include <stdlib.h>
#include <unistd.h>
char *get_next_line(int fd)
{
if (BUFFER_SIZE < 1 || fd < 0 || read(fd, NULL, 0) < 0) { return (NULL); }
char *line = malloc(100000), *buf = line;
while (read(fd, buf, 1) > 0 && *buf++ != '\n');
return (buf > line) ? (*buf = 0, line) : (free(line), NULL);
}
@viruskizz
viruskizz / 42Bangkok-pushswap_checker_test.sh
Last active August 17, 2022 14:27
42Bangkok-pushswap checker test
#!/bin/bash
## Setup
FILE="checker"
## Constant Variable
GREEN="\033[1;32m"
GRAY="\033[1;37m"
CYAN="\033[1;36m"
BLUE="\033[1;34m"
YELLOW="\033[1;33m"
@viruskizz
viruskizz / 42Bangkok-pushswap_test.sh
Last active August 17, 2022 14:19
42Bangkok-pushswap fully test
#!/bin/bash
## Setup
FILE="push_swap"
## Constant Variable
GREEN="\033[1;32m"
GRAY="\033[1;37m"
CYAN="\033[1;36m"
BLUE="\033[1;34m"
YELLOW="\033[1;33m"
@viruskizz
viruskizz / 42Bangkok-push_swap_random_test.sh
Last active August 17, 2022 16:11
42Bangkok-push_swap random test
#!/bin/bash
## Setup
FILE="push_swap"
## Constant Variable
GREEN="\033[1;32m"
GRAY="\033[1;37m"
CYAN="\033[1;36m"
BLUE="\033[1;34m"
YELLOW="\033[1;33m"
@viruskizz
viruskizz / basic-git-cmd.sh
Last active May 7, 2022 16:06
Basic git commands
## Get starting use git
# create git from empty
git init
# download project into your directory
git clone <url>
git clone <url> <dirname> #rename default project as you wish
## STATUS
# Check your git status