Skip to content

Instantly share code, notes, and snippets.

@adimiti
adimiti / itulookup.py
Created September 8, 2022 13:18
A call sign prefix lookup
# The source is https://en.wikipedia.org/wiki/ITU_prefix
data = {\
"A[A-L]": "United States",
"A[M-O]": "Spain",
"A[P-S]": "Pakistan",
"A[T-W]": "India",
"AX": "Australia",
"A[Y-Z]": "Argentina",
"A2": "Botswana",
"A3": "Tonga",
@adimiti
adimiti / ComPort over Network.md
Created April 7, 2022 07:01 — forked from DraTeots/ComPort over Network.md
ComPort over Network
@adimiti
adimiti / rep_m.py
Created March 30, 2022 14:38
montly working days report
import datetime, calendar
def get_month_days(date):
counter = datetime.datetime(date.year, date.month, 1, tzinfo=date.tzinfo)
date_list = []
while date.month == counter.month:
date_list.append(counter)
counter += datetime.timedelta(days=1)
return date_list
@adimiti
adimiti / .clang-format
Created November 15, 2021 14:31
.clang-format BSD style
# $FreeBSD$
# Basic .clang-format
---
BasedOnStyle: WebKit
AlignAfterOpenBracket: DontAlign
AlignConsecutiveAssignments: false
AlignConsecutiveDeclarations: false
AlignEscapedNewlines: Left
AlignOperands: false
AlignTrailingComments: true
@adimiti
adimiti / dos2unix.c
Created September 2, 2021 18:16
dos path to unix
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
char *process_drive(char *s)
{
char *p;
char *c;
@adimiti
adimiti / f2f.py
Created May 7, 2021 10:00
parse 2d C array
data = '''
static const unsigned char array[3][5] =
{
{ 0x00, 0x01, 0x02, 0x03, 0x04 }, // " "
{ 0x10, 0x11, 0x12, 0x13, 0x14 }, // X
{ 0x20, 0x21, 0x22, 0x23, 0x24 }, // ~
};
'''
import re
@adimiti
adimiti / lstrip.c
Created March 8, 2021 15:48
lstrip POC in c
#include <stdio.h>
int main(int argc, char *argv[])
{
int i;
char *tv[] = {
"no space",
" one space",
" more spaces",
};
@adimiti
adimiti / ooppoc.py
Created February 5, 2021 16:50
[OOP] 10x RYO !
# Thanks RYO for the hints
class MyBase:
name = 'Base'
grazelist = []
def __init__(self, x=None):
print 'Base:', x
if x:
self.x = x
def graze(self, x):
#include <stdint.h>
#include <stdio.h>
#include <string.h>
int printTabNumber(int x)
{
uint32_t c = ((x<0?'-':' ') << 8) | 0x20UL;
uint32_t s[3] = {0x20202020UL, 0x20202020UL, c};
int i;
union
@adimiti
adimiti / binfiles.cpp
Created July 16, 2020 06:20
For binary files, reading and writing data with the extraction and insertion operators (<< and >>) and functions like getline is not efficient, since we do not need to format any data and data is likely not formatted in lines.
// reading an entire binary file
#include <iostream>
#include <fstream>
using namespace std;
int reading()
{
streampos size;
char * memblock;