Skip to content

Instantly share code, notes, and snippets.

View jef-sure's full-sized avatar

Anton Petrusevich jef-sure

  • Germany
View GitHub Profile
@jef-sure
jef-sure / main.dart
Last active February 16, 2024 13:00
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
final class SwitchState {
static const on = 1;
static const enabled = 2;
final int state;
const SwitchState(this.state);
@jef-sure
jef-sure / esp32_perf_test.c
Last active December 29, 2022 09:54
ESP32 Indirect function call performance test
#include <stdint.h>
#include <stdio.h>
#include <stdbool.h>
#include <unistd.h>
#include <limits.h>
#include "esp_timer.h"
#include "esp_task_wdt.h"
#define TEST_COUNT 10000000
function clamp(rgb) {
return rgb < 0 ? 0 : rgb > 255 ? 255 : parseInt(rgb);
}
function weatherTempToRGB(temp) {
let r, g, b;
if (temp >= 23) {
let t = (temp - 23) / 27.0;
g = (1 - t) * 200;
r = 200 + t * 50;
#include <Arduino.h>
#include <Wire.h>
#include <math.h>
#include "SPI.h"
#include "TFT_eSPI.h"
#define TFT_GREY 0x7BEF
#include "esp_log.h"
#include "nvs_flash.h"
/* BLE */
#include "esp_nimble_hci.h"
#include "nimble/nimble_port.h"
#include "nimble/nimble_port_freertos.h"
#include "host/ble_hs.h"
#include "host/util/util.h"
#include "console/console.h"
#include "services/gap/ble_svc_gap.h"
import glob
import os
import re
spath = os.path.dirname(os.path.realpath(__file__))
all_fonts = [fon[len(spath)+1:] for fon in glob.glob(spath + '/fonts/*.c')]
all_headers = [re.sub(r"\.c$", ".h", f) for f in all_fonts]
root = spath + "/../../..";
used = {}
for cdir, subdirs, files in os.walk(root):
use PDF::Haru;
use Text::QRCode;
use POSIX 'floor';
use strict;
use warnings;
# create new document
my $pdf = PDF::Haru::New();
#$pdf->LoadTTFontFromFile("/usr/share/fonts/truetype/msttcorefonts/arial.ttf", HPDF_TRUE);
# add page
sub _php_jquery_param {
my ($root, $path, $value) = @_;
my @struct = $path =~ /\[?([^\[\]]+)\]?/g;
return if !@struct;
my $sl = \$root;
for my $key (@struct) {
if ($key =~ /^\d+$/) {
$$sl //= [];
$sl = \$$sl->[$key];
} else {
use PDF::Haru;
use POSIX 'floor';
use strict;
use warnings;
# create new document
my $pdf = PDF::Haru::New();
#$pdf->LoadTTFontFromFile("/usr/share/fonts/truetype/msttcorefonts/arial.ttf", HPDF_TRUE);
# add page
my $page = $pdf->AddPage();
#!/usr/bin/perl
use Benchmark qw(cmpthese);
use Config;
use Inline C => Config =>
# BUILD_NOISY => 1,
# FORCE_BUILD => 1,
OPTIMIZE => " -O3 -march=native";
use Inline C => <<'END_OF_C_CODE';
SV* lines_in_string(SV* sv) {