Skip to content

Instantly share code, notes, and snippets.

View ghoomfrog's full-sized avatar
🪰
losin'

ghoom ghoomfrog

🪰
losin'
  • Agadir, Morocco
  • 03:57 (UTC +01:00)
  • Reddit u/Unlimiter
View GitHub Profile
#include<limits.h>
#include<stdio.h>
#include<math.h>
// arithmetical definition of "abs"
int abs(int i) {
return pow((i*i), 0.5);
}
int f1(int num)
@ghoomfrog
ghoomfrog / upisc.c
Last active May 24, 2019 19:14
A method to compress strings of digit pairs to strings of predefined symbols.
/* upisc (Unlimiter's Pair-based Integer String Compression)
* A method to compress strings of digit pairs into strings of predefined symbols.
* The symbol dictionary doesn't contain every possible combination of pairs, but pairs that can be reversed to produce other pairs.
*
* In the command line, the program takes 1 argument, the integer string you want compress. It must have an even length.
* If one of the pairs in the argument is not in the dictionary, the program reverses it then translates it, after that, it puts a dot after it to denote it has been reversed.
*
* — Unlimiter
*/
@ghoomfrog
ghoomfrog / extract_from_date.c
Last active May 27, 2019 08:48
Functions to extract the year, the month and the day of a date integer (like 20151126), without using strings.
/* Functions to extract the year, the month and the day of a date integer (like 20151126), without using strings.
*
* by Unlimiter
*/
#include <stdio.h>
#include <math.h>
// returns the number of digits in an integer
int get_int_len(int n) {
@ghoomfrog
ghoomfrog / code.c
Last active June 5, 2019 02:20
Program to get ASCII codes of characters.
#include <stdio.h>
int main(int argc, char** argv) {
// if at least an argument is given to the program
if (argc > 1) {
// loop through first argument
for (int i = 0; argv[1][i] != 0; i++)
// print integer representation of character at i
printf("%i ", argv[1][i]);
puts("");
@ghoomfrog
ghoomfrog / sum.c
Created June 5, 2019 02:17
Program to quickly sum integers from a start to an end.
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char** argv) {
// if at least 2 arguments are given to the program
if (argc > 2) {
// first integer
long long f = atoll(argv[1]);
// last integer
long long l = atoll(argv[2]);
@ghoomfrog
ghoomfrog / uvector.h
Last active February 8, 2023 17:13
My vector implementation for C.
/* MIT License
Copyright (c) 2019-2020 Unlimiter
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
@ghoomfrog
ghoomfrog / oop.lua
Last active January 17, 2020 15:16
Simple OOP functions for Lua.
--[[
MIT License
Copyright (c) 2019 Unlimiter
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is

Keybase proof

I hereby claim:

  • I am ghoomy on github.
  • I am ghoomy (https://keybase.io/ghoomy) on keybase.
  • I have a public key ASDVGQWhmo_Y2QPaFanfrXqv_p2EydST1R9eA8AzFPGEBwo

To claim this, I am signing this object:

@ghoomfrog
ghoomfrog / crypt.c
Created May 23, 2021 04:09
The crypt function from unistd.h as a command.
#include <unistd.h>
#include <string.h>
#include <stdio.h>
int main(int argc, char **argv) {
if (argc > 1) {
if (argc > 2) {
char salt[3];
salt[0] = *argv[2];
if (strlen(argv[2]) < 2)
@ghoomfrog
ghoomfrog / darray.h
Last active August 9, 2021 02:46
Dynamic Array Facilities
#ifndef DARRAY_H
#define DARRAY_H
#define DARRAY_INITIAL_CAPACITY 64
#include <stdlib.h>
#include <string.h>
typedef struct darray_t {
size_t length, capacity;
void **elements;