Skip to content

Instantly share code, notes, and snippets.

View kesor's full-sized avatar
🏠
Working from home

Evgeny Zislis kesor

🏠
Working from home
View GitHub Profile
@kesor
kesor / scratch.sh
Created November 9, 2024 12:30
wm scratchpad script
#!/bin/sh
name=$1
case "$name" in
speedcrunch)
win_ids=$(xdotool search --classname "SpeedCrunch")
visible_win=""
hidden_win=""
@kesor
kesor / indicator-reader-blocking.ino
Created September 19, 2024 14:05
Arduino code for Chinesium Calipers or Dial Indicator digital output
int bit_array[25]; // For storing the data bit. bit_array[0] = data bit 1 (LSB), bit_array[23] = data bit 24 (MSB).
unsigned long time_now; // For storing the time when the clock signal is changed from HIGH to LOW (falling edge trigger of data output).
int CLOCK_PIN = 2;
int DATA_PIN = 3;
void setup() {
Serial.begin(115200);
pinMode(CLOCK_PIN, INPUT);
@kesor
kesor / eslint.config.ts
Last active July 7, 2024 11:05
ESLing Flat Config Typescript
/**
* @file
* ESLint configuration for a monorepo project
*/
import { default as pluginTs, Config } from 'typescript-eslint'
import { FlatCompat } from '@eslint/eslintrc'
import globals from 'globals'
import jsdoc from 'eslint-plugin-jsdoc'
import pluginJs from '@eslint/js'
import pluginJson from 'eslint-plugin-json'
@kesor
kesor / beltmatic_solver.py
Last active July 23, 2024 20:57
BFS-based Solver for the Game Beltmatic
#!/usr/bin/python3
from collections import deque
MAX_NUMBER = 18
# Define operations as functions
def add(x, y): return x + y
def sub(x, y): return x - y
def mul(x, y): return x * y
@kesor
kesor / pivot-sr.pine
Last active May 23, 2024 23:34
TradingView Pine Script indicator for Pivot points and Support-Resistance lines
//@version=5
indicator("Pivot SRs", overlay=true)
lookback = input.int(12, "Lookaround bars")
number_of_lines = input.int(5, "Lines to keep")
getLastNonNaInfo(series) =>
float lastValue = na
int lastIndex = na
for i = 0 to 1000 // Adjust the range as necessary
@kesor
kesor / multi-ma.pine
Created May 23, 2024 23:21
Multiple Moving Averages for TradingView Pine Script
// @version=5
indicator(title="Multi-MA", shorttitle="MA", overlay=true)
var string MA_EMA = "EMA" // (Exponential Moving Average)"
var string MA_SMA = "SMA" // (Simple Moving Average)"
var string MA_WMA = "WMA" // (Weighted Moving Average)"
var string MA_HMA = "HMA" // (Hull Moving Average)"
var string MA_RMA = "RMA" // (Relative Moving Average)"
var string MA_SWMA = "SWMA" // (Symmetrically-Weighted Moving Average)"
@kesor
kesor / interrupt-based-reader.ino
Last active April 18, 2024 01:09
Digital Caliper / Digital Dial Indicator Arduino reader
/**
* Arduino Sketch for Digital Calipers and Dial Indicators Reading
*
* This sketch is designed to interface with digital calipers or dial indicators, reading measurements
* via a simple two-pin setup. It effectively handles data on both rising and falling edges of a clock signal,
* managing debouncing and differentiating between measurement units (inches or millimeters).
*
* Features:
* - Uses interrupts to capture data from clock signal changes.
* - Debouncing logic for accurate edge detection.
@kesor
kesor / broken-chatgpt-tampermonkey.js
Created December 13, 2022 03:50
This is a voice Synthesis for ChatGPT that unfortunately doesn't work right now
// ==UserScript==
// @name ChatGPT Speak and Listen
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author https://gist.github.com/kesor
// @downloadURL https://gist.github.com/kesor/fc0d1a9b285011b74670109f22a59670
// @match https://chat.openai.com/chat
// @grant unsafeWindow
// ==/UserScript==
@kesor
kesor / 1-voice-synthesis.js
Last active March 7, 2024 00:19
Making chat OpenAI use TTS
// paste this into your chrome dev console for Speech Synthesis
const originalFetch = window.fetch
const patchedFetch = (...args) => {
if (args[1].method == 'POST' && args[1].body.length > 0 && /moderations$/.test(args[0])) {
const aiResponse = JSON.parse(args[1].body)["input"].split("\n\n\n")
if (aiResponse.length > 1) {
const text = aiResponse.slice(1).join(". ").trim()
console.log(text)
@kesor
kesor / seafile-nginx.conf
Created September 22, 2021 17:58
seafile-nginx.conf
server {
listen 80;
listen [::]:80;
server_name seafile.example.com;
root /usr/local/www/nginx;
error_page 500 502 503 504 /50x.html;
location = 50x.html {
root /usr/local/www/nginx-dist;
}