Skip to content

Instantly share code, notes, and snippets.

View uidops's full-sized avatar
☄️
_-_-_-_- ^ -_-_-_-_

joe uidops

☄️
_-_-_-_- ^ -_-_-_-_
View GitHub Profile
@uidops
uidops / xo.py
Created January 4, 2023 08:00
minimax tic-tac-toe in python
import math
import operator
import os
import secrets
import sys
import time
players = ('U', 'C', '0')
func = (min, max)
@uidops
uidops / exp_ln_pow.py
Last active April 11, 2023 17:56
exp, ln and pow
from ctypes import c_uint64, c_double
o = (c_uint64.from_buffer(c_double(1)).value >> 0x20) - 0xed81
def exp(x: float) -> float:
x = int((0x171547 * x) + o) << 0x20
return c_double.from_buffer(c_uint64(x)).value
def ln(x: float) -> float:
x = c_uint64.from_buffer(c_double(x)).value >> 0x20
@uidops
uidops / iran.c
Last active October 28, 2022 11:36
FREEDOM
#include <time.h>
#include <stdio.h>
#include <stdlib.h>
#define clear_screen fputs("\x1b[2J\x1b[H", stdout);
int
main(void)
{
const unsigned long long data[] = {
@uidops
uidops / 059-XOR_decryption.c
Last active August 28, 2022 12:31
#59 XOR decryption
/*
* #59 XOR decryption - Project Euler [ https://projecteuler.net/problem=59 ]
* the numbers: https://projecteuler.net/project/resources/p059_cipher.txt
*/
#include <stdio.h>
int isvalid(const char);
int
@uidops
uidops / 089-Roman_numerals.c
Created August 25, 2022 10:40
#89 Roman numerals
/*
* #89 Roman numerals - Project Euler [ https://projecteuler.net/problem=89 ]
*
* The fastest way to solve this problem is replacing (but we will not replace).
* When we look at the numbers in the file, we found many numbers that can be written shorter.
* Those numbers are:
* . IIII = IV = 4
* . VIIII = IX = 9
* . XXXX = XL = 40
* . LXXXX = XC = 90
@uidops
uidops / meminfo.c
Last active June 1, 2022 09:13
Reading /proc/meminfo and calculating used memory based on procps-ng's free calculation method
#include <err.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MEMINFO "/proc/meminfo"
struct meminfo {
@uidops
uidops / rflags.py
Created March 30, 2022 16:36
RFLAGS
import sys
def bin_to_dec(b):
number = 0
l = len(b) - 1
for char in b:
number += int(char)*(2**l)
l -= 1
@uidops
uidops / cube.s
Last active December 30, 2021 09:19
CUBE (x86-64)
/*
CUBE (x86-64)
Compile: cc -no-pie -nostartfiles cube.s -o cube
C code:
#include <stdio.h>
#include <stdlib.h>
long int
cube(int x)
@uidops
uidops / random_pacman.py
Created December 24, 2021 16:36
random pacman
#!/usr/bin/python3
import subprocess
import random
import os
cows = [
"ghost",
"radio",
"pod",
"udder",
@uidops
uidops / fib.s
Last active November 20, 2021 13:42
Fibonacci sequence in assembly language (x86)
/*
Fibonacci sequence in assembly language (x86)
Compile: clang -m32 -no-pie -nostartfiles fib.s -o fib
C code:
#include <stdio.h>
int
main(void)