Skip to content

Instantly share code, notes, and snippets.

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

joe uidops

☄️
_-_-_-_- ^ -_-_-_-_
View GitHub Profile
@uidops
uidops / volume.c
Created July 7, 2023 21:30
volume controller
#include <pulse/pulseaudio.h>
#include <err.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
uint8_t flag = 0;
uint8_t volume = 0;
@uidops
uidops / bst.c
Created June 5, 2023 15:22
Binary search tree (BST)
#include <sys/param.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
struct node {
uint32_t data;
struct node *left, *right;
};
@uidops
uidops / sll.c
Created June 5, 2023 09:11
Singly linked list in c
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
struct node {
uint8_t a;
struct node *next;
};
@uidops
uidops / md5.c
Last active April 30, 2023 17:03
MD5 - The MD5 Message-Digest Algorithm
/*
* MD5 - The MD5 Message-Digest Algorithm
* https://www.ietf.org/rfc/rfc1321.txt
*
*/
#include <err.h>
#include <stdint.h>
#include <stdio.h>
@uidops
uidops / hton.c
Created April 21, 2023 19:28
hton
#include <stdint.h>
#define ntohs(n) htons(n)
#define ntohl(n) htonl(n)
#define x86_ntohs(n) x86_htons(n)
#define x86_ntohl(n) x86_htonl(n)
uint16_t
htons(uint16_t n)
@uidops
uidops / b64encode.c
Last active March 22, 2023 13:50
b64encode
#include <sys/mman.h>
#include <err.h>
#include <fcntl.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
void b64encode(void *, size_t, void *);
@uidops
uidops / mul.c
Last active March 25, 2023 09:32
Binary multiplication
#include <stdint.h>
#define SIGN(X) ((X >> 0x0000001f) & 0x00000001)
#define ABS(X) ((X^(X >> 0x0000001f)) - (X >> 0x0000001f))
#define SWAP(X, Y) (((X) ^= (Y)), ((Y) ^= (X)), ((X) ^= (Y)))
uint32_t umul(uint32_t, uint32_t);
int32_t smul(int32_t, int32_t);
@uidops
uidops / setbit.py
Last active February 23, 2023 20:13
SETBIT COUNTER
#!/usr/bin/env python
x = 0x000EAFFA
# bin()
c = bin(x).count('1')
print(c)
@uidops
uidops / p2w.py
Created February 8, 2023 16:22
Persian number to words
import math
numbers = ('صفر', 'یک', 'دو', 'سه', 'چهار', 'پنج', 'شش', 'هفت', 'هشت', 'نه',
'ده', 'یازده', 'دوازده', 'سیزده', 'چهارده', 'پانزده', 'شانزده', 'هفده', 'هجده', 'نوزده')
excep_scales = ('بیست', 'سی', 'چهل', 'پنجاه', 'شصت', 'هفتاد', 'هشتاد', 'نود',
'صد', 'دویست', 'سیصد', 'چهارصد', 'پانصد', 'ششصد', 'هفتصد', 'هشتصد', 'نهصد')
short_scales = ('هزار', 'میلیون', 'بیلیون', 'تریلیون',
'کوآدریلیون', 'کوینتیلیون', 'سکستیلیون', 'سپتیلیون',
@uidops
uidops / sal.py
Created February 8, 2023 16:17
Snakes and ladders
import random
n = 100
snakes = {17: 7, 52: 32, 62: 19, 64: 60, 87: 24, 93: 72, 95: 75, 99: 78}
ladders = {4: 14, 9: 31, 20: 38, 28: 84, 40: 59, 51: 67, 63: 81, 71: 91}
position = [0, 0]
player = 0