Skip to content

Instantly share code, notes, and snippets.

View the-code-innovator's full-sized avatar
🎯
Focusing

Aravind Muthukrishnan the-code-innovator

🎯
Focusing
View GitHub Profile
@the-code-innovator
the-code-innovator / ascii.py
Last active July 11, 2023 01:55
printable ascii (csv,md) generator - 725 char
import string,csv
c,h,n,o,p={9:"HT",10:"LF",11:"VT",12:"FF",13:"CR",32:"SP",34:"QT",44:"CM",96:"BT",124:"VB"},['dec','hex','chr'],'ascii',lambda x:ord(x[1]),string.printable
csv.writer(open(n+'.csv','w')).writerow(h),csv.writer(open(n+'.csv','a')).writerows([[str(j[0]),hex(j[0]),'<'+c[j[0]]+'>']if j[0]in c.keys()else[str(j[0]),hex(j[0]),j[1]]for j in sorted([[ord(i),i]for i in p],key=o)]),open(n+'.md','w').writelines(['|'+'|'.join(h)+'|\n','|'+'|'.join(["---"for i in range(len(h))])+'|\n']+['|'+'|'.join([j[0],j[1],'\\<'+j[2]+'>'])+'|\n'if int(j[0]) in c.keys()else'|'+'|'.join(j)+'|\n'for j in[[str(j[0]),hex(j[0]),c[j[0]]]if j[0]in c.keys()else[str(j[0]),hex(j[0]),j[1]]for j in sorted([[ord(i),i]for i in p],key=o)]])
@the-code-innovator
the-code-innovator / fast_inverse_sqrt.c
Created December 31, 2020 21:02
fast_inverse_sqrt
float fast_inverse_sqrt(float input) {
long i;
float x2, y;
const float three_half = 1.5F;
x2 = input * 0.5F;
y = input;
i = * ( long * ) &y;
i = 0x5f3759df - ( i >> 1);
y = * ( float * ) &i;
for (int i = 0; i < 10; i++) {
@the-code-innovator
the-code-innovator / results.txt
Last active April 4, 2020 19:56
MPMP: Can you spin the table ? (https://youtu.be/T29dydI97zY)
[1, 3, 5, 7, 2, 4, 6]
[1, 3, 6, 2, 7, 5, 4]
[1, 3, 7, 6, 4, 2, 5]
[1, 4, 2, 7, 6, 3, 5]
[1, 4, 6, 3, 2, 7, 5]
[1, 4, 7, 2, 6, 5, 3]
[1, 4, 7, 3, 6, 2, 5]
[1, 4, 7, 5, 3, 2, 6]
[1, 5, 2, 6, 3, 7, 4]
[1, 5, 4, 2, 7, 3, 6]
@the-code-innovator
the-code-innovator / parkinsons-disease-replicated-acoustic-features.ipynb
Last active November 24, 2019 17:04
parkinsons-disease-replicated-acoustic-features
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@the-code-innovator
the-code-innovator / vernam.c
Created May 2, 2019 03:46
vernam - vernam cipher implementation in c
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
char get_translated_char(char key, char plaintext) {
return (char)(((tolower(key) + tolower(plaintext) - 194) % 26) + 97);
}
char* get_translation_key(size_t key_length, char *key, size_t plaintext_length, char *plaintext) {
#include <stdio.h>
#include <stdlib.h>
typedef struct __modal_node_wo__ {
int data;
size_t count;
}* modal_node_wo_t;
typedef struct __modal_node__ {
int data;
@the-code-innovator
the-code-innovator / cconfig.c
Created April 18, 2019 14:43
cconfig - a barebones config file reader
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define CONFIG_ARGUMENT_FLAG "-C"
char* get_config_by_name(FILE *config_file, char *config_name) {
char *config_property = (char*)malloc(sizeof(char) * 40);
char *config_value = (char*)malloc(sizeof(char) * 40);
while(!feof(config_file)) {
@the-code-innovator
the-code-innovator / multiplicative_persistence.py
Created March 21, 2019 19:04
Implementation of the Multiplicative Persistence of a Number in python3 -- [wolfram-mathworld - https://tinyurl.com/yhovkf9]
#!/usr/local/bin/python3.7
def multiplicative_persistence(number, verbose = True):
count = 0
if verbose == True:
print('pass ' + str(count) + ': ' + str(number))
while len(str(number)) != 1:
product = 1
for i in [int(j, 10) for j in list(str(number))]:
product *= i
@the-code-innovator
the-code-innovator / cointoss.c
Created November 5, 2018 09:32
pseudorandom(int) for coin toss result.
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
typedef enum coin {
HEAD = 0,
TAIL = 1
} coin_t;
int randomRange(int lower, int upper) {
@the-code-innovator
the-code-innovator / equation.gif
Last active September 30, 2018 08:09
fibbonacci - Θ(1)
equation.gif