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 / component-app.js
Last active April 23, 2024 15:18
Vue.js 3.x with ES6 modules in the browser using import-map
import { defineAsyncComponent } from 'vue'
const Content = defineAsyncComponent(() => import('./component-content.js'))
export default {
name: 'App',
components: { Content },
template: /*html*/`
<Content />
`
@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 / 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 / gist:1179782
Created August 30, 2011 00:27
Google AppEngine URLFetch in Unit Tests
from google.appengine.api import apiproxy_stub
from google.appengine.api import apiproxy_stub_map
class FetchServiceMock(apiproxy_stub.APIProxyStub):
def __init__(self, service_name='urlfetch'):
super(FetchServiceMock, self).__init__(service_name)
def set_return_values(self, **kwargs):
self.return_values = kwargs
@kesor
kesor / Dockerfile
Last active August 11, 2023 21:17
Compile DENO on Alpine (w/MUSL C)
FROM rust:alpine
RUN apk add --no-cache \
bash \
binutils-gold \
ca-certificates \
clang \
curl \
g++ \
git \
@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 / an upstart unicorn.conf
Last active February 9, 2022 09:20
Unicorn that receives USR2 signal on upstart's "stop unicorn", but also allows upstart to respawn it when for some reason it crashed on its own.
# unicorn
description "unicorn ruby app server"
start on (local-filesystems and net-device-up IFACE=lo and runlevel [2345])
stop on runlevel [!2345]
env WORKDIR=/data
env PIDFILE=/data/tmp/pids/unicorn.pid
env CFGFILE=/data/config/unicorn.rb
@kesor
kesor / cloudtrail-template-elasticsearch.json
Last active February 5, 2022 02:59
An ElasticSearch Index template for CloudTrail events
PUT _template/cloudtrail
{
"index_patterns": ["cloudtrail-*"],
"settings": {
"number_of_shards": 1,
"mapping": {
"total_fields": {
"limit": 10000
}
}
@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;
}
@kesor
kesor / sql_mongodb_dump_middleware.py
Created January 10, 2012 15:38
Django MongoDB + SQL dump middleware
from django.core.exceptions import MiddlewareNotUsed
from django.conf import settings
from django.db import connection
from pymongo.connection import Connection
from time import time
import struct
import bson
from bson.errors import InvalidBSON
class SqldumpMiddleware(object):