Skip to content

Instantly share code, notes, and snippets.

@lexmihaylov
lexmihaylov / manualFKeys.ahk
Last active August 30, 2019 12:23
AHK manual function keys
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
HotkeyList := []
activateWindow(index) {
global HotkeyList
winId := HotkeyList[index]
@lexmihaylov
lexmihaylov / Mutex.js
Created June 17, 2019 14:59
A very simple Mutex implementation to be used in combination with `SharedArrayBuffer` and `Atomics`
class Mutex {
static from(mutexLikeStruct) {
let instance = new this();
try {
instance.shared = mutexLikeStruct.shared;
} catch(ex) {
throw new TypeError('Structure does not have a shared property');
}
(function() {
'use strict';
function IOSArrowKeys(selector) {
this.targetSelection = 0;
this.selector = selector;
this.focused = null;
this.lock = false;
if(!/iPad|iPhone|iPod/.test(navigator.userAgent)) return;
@lexmihaylov
lexmihaylov / caret-position.js
Last active February 28, 2018 14:30
Tries to create a range from a given point on the screen
(function() {
function getTextRect(textNode) {
if (textNode.nodeType != 3) {
return textNode.getBoundingClientRect()
}
var range = document.createRange();
range.selectNode(textNode);
var textNodeRect = range.getBoundingClientRect();
range.detach();
return textNodeRect;
0x69e37d392985CC247F199418B693864A950572CA
@lexmihaylov
lexmihaylov / word-processor.js
Created April 7, 2016 11:48
Word processor for selection highlighter meant to be used with GoogleChrome's speechSynthesis engine.
(function() {
'use strict';
/**
* List of all punctuation marks that are allowed in the sanitized text
* Note: this can be extended in the future
* @type {String}
* @const
*/
var AllowedPunctuatio = ":!\\?\\.,'`<>\\+\\-=/\\\\";
@lexmihaylov
lexmihaylov / native-hash.js
Last active January 2, 2018 03:29
Hashing using the native crypto api and native promise api
function arrayBufferToStringAsync( /*ArrayBuffer*/ buffer) {
var reader = new FileReader();
return readAsync(reader, 'Text', new Blob([buffer])).then(function() {
return new Promise(function(resolve, reject) {
resolve(reader.result);
});
});
};
function arrayBufferToHexAsync( /*ArrayBuffer*/ buffer) {
@lexmihaylov
lexmihaylov / libs.chat_server.rb
Created October 2, 2015 11:47
Multithreaded chat server developed in ruby
require 'socket'
require_relative 'client'
class ChatServer
def initialize(port, host)
@host = host || 'localhost'
@port = port
@server = nil
@clients = []
@lexmihaylov
lexmihaylov / polar-numix.sh
Last active August 29, 2015 14:10
Install Polar Night Theme with Numix Icon Theme
# install polar night theme
sudo add-apt-repository ppa:noobslab/themes
sudo apt-get update
sudo apt-get install polar-night-gtk
# install numix circle icon theme
sudo add-apt-repository ppa:numix/ppa
sudo apt-get update
sudo apt-get install numix-icon-theme numix-icon-theme-bevel
<script>
$(function() {
$('#layout').layout({
type: 'vertical',
resizable: true,
helper: false,
panes: [
['#pane1', {minWidth: 200, maxWidth: 400}],
['#pane2']
]