Skip to content

Instantly share code, notes, and snippets.

View TeWu's full-sized avatar
💭
Loading...

Tomasz Więch TeWu

💭
Loading...
View GitHub Profile
@TeWu
TeWu / Z3_incorrect_ignore_model.py
Created January 2, 2021 20:48
Z3 incorrect ignore model in solver
from z3 import *
inp_length = 2
vec = ''
for i in range(0,inp_length):
vec += f"inp[{i}] " # inp[0] inp[1]
inp = BitVecs(vec, 8)
solver = Solver()
@TeWu
TeWu / ruby_bench_max.rb
Last active March 12, 2020 11:49
Benchmark finding max value
require 'benchmark/ips'
def fast(a, b)
a > b ? a : b
end
def slow(a, b)
[a, b].max
end
@TeWu
TeWu / MT1422_button_codes.md
Last active May 30, 2021 11:32
Button codes (key codes) for Media-Tech MT1422 (a.k.a MX3)

Media-Tech MT1422 button codes (for [Kodi][0])

Media-Tech MT1422

This is a list of button codes (key codes) on the [Media-Tech MT1422][1] remote and air mouse (similar to [MX3][3] remote). Those codes can be used to customize the remote by creating a custom [keymap][2].

The buttons codes are intended for use with [Kodi media center][0]. The list was created by inspecting the [debug log][4] of Kodi 18.5 (tail -f ~/.kodi/temp/kodi.log | grep HandleKey).

@TeWu
TeWu / refresh_ws_wallpaper.rb
Created September 8, 2019 18:20
Get image from Windows Spotlight
## Removes previous wallpaper file, and gets new image from Windows Spotlight
require 'fileutils'
require 'exifr/jpeg'
SPOTLIGHT_IMAGES_PATH = File.join(ENV["LocalAppData"].split('\\') + ["Packages", "Microsoft.Windows.ContentDeliveryManager_cw5n1h2txyewy", "LocalState", "Assets"])
WALLPAPER_FILENAME_FILE = "currect_wallpaper_filename.txt"
spotlight_image_path = Dir[File.join(SPOTLIGHT_IMAGES_PATH, "*")]
.select{|f| File.size(f) > 50e3 }
@TeWu
TeWu / good_educational_stuff.md
Last active July 12, 2019 11:57
Good Educational Playlists
@TeWu
TeWu / repeat_f.ahk
Last active January 23, 2020 20:01
Repeat pressing F fast
SetKeyDelay 30, 20
~XButton1 & f::
while GetKeyState("XButton1")
Send f
return
@TeWu
TeWu / wtf.rb
Created March 9, 2019 20:54
Huh!?
def test
return true
ensure
return false
end
test #=> false
def test2
true
@TeWu
TeWu / is_daylight_saving_time_in_poland.c
Last active February 27, 2019 12:40
Daylight saving time calculation
// is PoLish Daylight Saving Time - source: https://en.wikipedia.org/wiki/Daylight_saving_time_by_country
// month - Month (1..12)
// date - Day of the month (1..31)
// dow - Day Of Week (1..7)
uint8_t isPLDST(uint8_t month, uint8_t date, uint8_t dow) {
if (month < 3 || month > 10) return 0;
if (month > 3 && month < 10) return 1;
uint8_t prevSunday = date > dow ? date - dow : 0;
if (month == 3) return prevSunday >= 25;
else // month == 10
@TeWu
TeWu / TWI_switch.c
Created February 14, 2019 12:16
TWI ISR swtich statement
ISR(TWI_vect) {
switch(TW_STATUS) {
// NOTE: SLA+W = SLave Address + Write bit
// SLA+R = SLave Address + Read bit
// All
case TW_NO_INFO: // No state information available
case TW_BUS_ERROR: // Bus error; Illegal START or STOP condition
// All Master
@TeWu
TeWu / zegar_fazowy.c
Last active January 27, 2019 09:54
Zegar fazowy w kilku językach programowania
#include <stdio.h>
#include <time.h>
#define PRINT_PHASE_TIME(phase, moment) printf("%02d:%02d\r\n", phase, moment);
#define INCREMENT_PHASE_TIME(phase, moment) moment++;\
if (moment >= 100) {\
moment = 0;\
phase++;\
}\
if (phase >= 100) phase = 0;