Skip to content

Instantly share code, notes, and snippets.

View sadrok's full-sized avatar
🐉

Francois Basson sadrok

🐉
View GitHub Profile
#ifndef AVERAGER_H
#define AVERAGER_H
#include <stdint.h>
template <class T, uint8_t n> class Averager {
private:
uint8_t samples;
uint8_t idx;
const uint8_t maxSamples;
@sadrok
sadrok / generate_thumbnails.py
Created February 8, 2021 08:04
The thumbnail generation script running on my Azure site. It's (suppose to be) triggered automatically when I upload a file to the storage account.
import logging
import os
from io import BytesIO
from pathlib import PurePath
import azure.functions as func
from azure.identity import DefaultAzureCredential
from azure.storage.blob import BlobServiceClient, ContentSettings
from PIL import Image, UnidentifiedImageError
package main
import "golang.org/x/tour/tree"
import (
"fmt"
)
// Walk walks the tree t sending all values
// from the tree to the channel ch.
func Walk(t *tree.Tree, ch chan int) {
@sadrok
sadrok / iframe_directive.py
Last active June 2, 2024 16:29
Nikola plugin for inserting an iframe from reST
# -*- coding: utf-8 -*-
"""
iframe directive for reStructuredText.
basic use in reST document:
.. iframe:: https://google.com/
:width: 640
:height: 480
{
"extends": [
"standard",
"plugin:react/recommended"
],
"env": {
"browser": true,
"jest": true
},
"parser": "babel-eslint",
Line # Mem usage Increment Line Contents
================================================
6 14.6 MiB 0.0 MiB @profile
7 def find_largest_prime_smaller_than(maximum):
8 14.6 MiB 0.0 MiB x1 = time.clock()
9 14.6 MiB 0.0 MiB latest_prime = None
10 14.6 MiB 0.0 MiB x = (maximum // 2) * 2 + 1
11 14.6 MiB 0.0 MiB while x > 2 and not latest_prime:
12 14.6 MiB 0.0 MiB for i in xrange(3, x, 2):
13 14.6 MiB 0.0 MiB q = x / i
Line # Mem usage Increment Line Contents
================================================
6 132.4 MiB 0.0 MiB @profile
7 def find_largest_prime_smaller_than(maximum):
8 132.4 MiB 0.0 MiB x1 = time.clock()
9 132.4 MiB 0.0 MiB latest_prime = None
10 132.4 MiB 0.0 MiB x = (maximum // 2) * 2 + 1
11 1190.9 MiB 1058.5 MiB while x > 2 and not latest_prime:
12 1572.3 MiB 381.5 MiB for i in range(3, x, 2):
13 1572.3 MiB 0.0 MiB q = x / i
Starting jobs without monkey patching
http://www.google.com got <Response [200]> took 1.13251829249 seconds
http://www.python.org got <Response [200]> took 2.01172115155 seconds
http://sadrok.com got <Response [200]> took 0.416737742826 seconds
https://en.wikipedia.org/wiki/Python_(programming_language) got <Response [200]> took 1.56067030207 seconds
Real time 5.12775028815 seconds. Sum of individuals 5.12164748893 seconds
Starting jobs with monkey patching
http://www.google.com got <Response [200]> took 1.47563088431 seconds
http://www.python.org got <Response [200]> took 1.74336271832 seconds
#include <TimerOne.h>
#define CLK 8 //UNO:PORT_B0
#define FQ 9 //UNO:PORT_B1
#define DATA 10 //UNO:PORT_B2
#define RST 11 //UNO:PORT_B3
// PORT B on MEGA2560
//#define CLK 53
//#define FQ 52
// -- POPULATE THE TEXTAREA BITMAP
for (l = 0; l < LINES; l++)
{
for(y = 0; y < 11; y++)
{
for(c = 0; c < COLS; c++)
{
unsigned char ch = lines[l][c] - ' ';
unsigned char font_char_y = pgm_read_byte_near(font + y + (ch * 11)); //font[ch][y];
unsigned char mask = 0x80;