Skip to content

Instantly share code, notes, and snippets.

View fabiovila's full-sized avatar

Fabio fabiovila

View GitHub Profile
@fabiovila
fabiovila / lib.c
Last active June 1, 2024 02:06
Torch nn.Linear equivalent in C with cblas_sgemm ( bias = False ).
#include <cblas.h>
#include <omp.h>
// gcc -shared -o lib.so -fPIC lib.c -I/opt/intel/oneapi/mkl/2024.1/include/ -fopenmp -DMKL_ILP64 -m64 -I"$MKLROOT/include"
void clinear(float *A, int ashape[3], float *B, int bshape[3], float *C) {
int M = ashape[1];
int N = bshape[0];
int K = ashape[2];
@fabiovila
fabiovila / BITdefines.h
Created March 16, 2024 20:40
BIT Shifts defines
#define BIT0 1
#define BIT1 2
#define BIT2 4
#define BIT3 8
#define BIT4 16
#define BIT5 32
#define BIT6 64
#define BIT7 128
#define BIT8 256
#define BIT9 512
@fabiovila
fabiovila / openbox-tilling-keybinds.md
Last active March 16, 2024 20:40
Openbox tilling keybinds

Puts this xml code in section <keyboard> </keyboard> of ~/.config/openbox/rc.xml.

Shortcuts are then Window+Shift+[hjkl]

@fabiovila
fabiovila / html2txt.js
Created May 26, 2023 01:09
Export html files to plain and a clean text file
// Usage: node html2txt.js file
// example recursive: find . -name "*.html" -exec node html2txt.js.js {} \; >> out.txt
var { Readability } = require('@mozilla/readability');
var { JSDOM } = require('jsdom');
var fs = require('fs');
file = process.argv[2];
try {
let data = fs.readFileSync(file, 'utf8');
@fabiovila
fabiovila / app.py
Created April 8, 2023 18:40
OpenAI Bot for Telegram, also example of Flask and webhook pure requests bot for telegram, redis is used as update_id cache.
from flask import Flask, request, jsonify
import requests
from .bot import get_completion
import logging, sys
import redis
logging.basicConfig(stream=sys.stderr,level=logging.DEBUG, format="[FLASK] %(message)s")
app = Flask(__name__)
@fabiovila
fabiovila / amazon.py
Last active November 2, 2021 19:36
Um script que pesquisava por itens no programa de affiliados da Amazon.
import hmac, base64, hashlib
import base64, hashlib, hmac, time
import urllib.parse
def search(item):
AWS_ACCESS_KEY_ID = ''
AWS_SECRET_ACCESS_KEY = ''
ASSOCIATE = ''
@fabiovila
fabiovila / primes.lst
Created July 28, 2021 00:53
Prime numbers from 2 to 999983 in various format
2
3
5
7
11
13
17
19
23
29
@fabiovila
fabiovila / wacomtray.py
Created May 20, 2021 21:06
Systray app to change monitor target of wacom digitalizers. Also tray pyqt5 tray app example and base64 image embbeded
#!/usr/bin/python3
from PyQt5.QtGui import *
from PyQt5.QtWidgets import *
import os
import base64
icon64 = "iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAACXBIWXMAAA6cAAAOnAEHlFPdAAAAGXRFWHRTb2Z0d2FyZQB3d3cuaW5rc2NhcGUub3Jnm+48GgAABHRJREFUWMPtlm1sU1Ucxn/39vZlg62121rasZfigDFUFHQbS9BBQAOaNUIgIcaAmKifjImJaJRPJnwxxJgJGEhIXBAEgUgyfFmWYICYSYOuATJwr93Ya7uOlkLf7r3HD0OjgW1dffkiz8dzz/k/v/M/T8658ED/vOyA8780dAKfAt0mRUo67UbdVWgWQOXfKSpN860E2AP8ajFNGi7x5OrPrrTpB3ZViETbSnFwV4VwFZo7sjaSJOmkEKIL+AAoBt4HVlvMcol1jsFotxopnWdih9cheesL6RpU6Ri0k5RLeNx1BY8LHt38i94zmDDMBKDcb1AI0SdJ0uuyxDu2fEW4CkxUlJp5Y7NLWlttJTACl/vzkXM9NHeWU774aTa9WIMkSZzY28BST5j8uQY5kw4oU4y/PTdXfqvMZWYklJaeWJLPxg0riColfNnupnLZOho2VCNJ9zZQmD1AmPkOE+3Xb1cDF7MKgSJJ7fveXSA2rSsVRUVFora2Vvj9fjGTTh1tFGlfnWj6cJFwF5l6sjK/q8r6J62ip7lanDh+WKxZs0a4XC6xc+dOoWnalAD9gT7RdrhWxNtWiofnW7SZTKY7p2tDwZTwuI3o8T5aWlrYvn07TU1NrF+/HlVV77uopLSM/gknFpOMda4yYw6mnTARTeuRmAbxXgwGA7t376a1tRWbzUZXV9fUCy0LJmGcZoD6rAHCUdV36PQISrqPdDoNQFVVFceOHaOycup7xpi/kGRK5+UXiih2mA5nDaBpbPn6bJiaRTEu+c7P1M0/V
@fabiovila
fabiovila / sineplay.c
Created March 14, 2021 01:30
Playing sine wave in SDL2
#include <math.h>
#include <stdio.h>
#include <SDL2/SDL.h>
#include <SDL2/SDL_mixer.h>
#define FREQ 392 // G note
typedef struct {
double samplesPerSine;
uint32_t samplePos;
@fabiovila
fabiovila / index.js
Last active January 28, 2021 13:23
Basic box blinking loading component in React, Styled Components
import styled from 'styled-components';
const BoxBlink = styled.div`
@keyframes blinker {
50% {
opacity: 0;
}
}
animation: blinker 2s linear infinite;