Skip to content

Instantly share code, notes, and snippets.

View skt041959's full-sized avatar

skt041959 skt041959

View GitHub Profile
@skt041959
skt041959 / README.md
Created February 8, 2022 10:06 — forked from runiq/README.md
Neovim throttle & debounce

What are these?

Functions that allow you to call a function not more than once in a given timeframe.

Throttling on the leading edge

This can be illustrated with timing diagrams. In the following diagrams, f designates call to the throttled function, t is the period where the timer is running, and x shows you the actual execution point of the throttled function.

f 1  2  3  4  5  6
import vim
import re
import json
import asyncio
import logging
try:
from patiencediff import PatienceSequenceMatcher as SequenceMatcher
except ImportError:
from difflib import SequenceMatcher
test_osc() {
printf %b '\033]52;c;' $(date +"1_%m_%d_%H_%M" | base64) '\007'
printf %b '\033Ptmux;\033\033]52;c;' $(date +"2_%m_%d_%H_%M" | base64) '\007\033\\'
printf %b '\ePtmux;\e\ePtmux;\e\e\e\e]52;c;' $(date +"3_%m_%d_%H_%M" | base64) '\a\a\e\e\\\e\'
}
@skt041959
skt041959 / coc-location.py
Last active February 24, 2021 01:42
denite source of coc locations, such as references, symbols
import os
from pathlib import Path
from denite.base.source import Base
class Source(Base):
def __init__(self, vim):
super().__init__(vim)
self.name = 'coc-locations'
self.kind = 'file'
@skt041959
skt041959 / umpv
Last active December 7, 2015 05:31
unique mpv player
#!/usr/bin/env python
"""
This script emulates "unique application" functionality on Linux. When starting
playback with this script, it will try to reuse an already running instance of
mpv (but only if that was started with umpv). Other mpv instances (not started
by umpv) are ignored, and the script doesn't know about them.
This only takes filenames as arguments. Custom options can't be used; the script
interprets them as filenames. If mpv is already running, the files passed to
@skt041959
skt041959 / usb_vmdk.sh
Created December 1, 2015 16:02
make usb disk
#!/bin/bash
# Erase old VMDK entries
rm ~/.VirtualBox/*.vmdk
# Clean up VBox-Registry
sed -i '/sd/d' ~/.VirtualBox/VirtualBox.xml
# Remove old harddisks from existing machines
find ~/.VirtualBox/Machines -name \*.xml | while read file; do
@skt041959
skt041959 / feh.sh
Created December 1, 2015 15:57
make feh open images under the same directory
#!/bin/bash
shopt -s nullglob
if [[ ! -f $1 ]]; then
echo "$0: first argument is not a file" >&2
exit 1
fi
file=$(basename -- "$1")
@skt041959
skt041959 / cltxt.py
Created December 1, 2015 15:55
download novel from 1024
#!/usr/bin/env python
# encoding: utf-8
import sys
import requests
from lxml import html
import re
import html2text
proxy = {"http" : "http://127.0.0.1:8123"}
@skt041959
skt041959 / qq.py
Last active March 19, 2016 09:35
start with python, and maintain the processes under python process
#!/usr/bin/env python
# encoding: utf-8
from ctypes import CDLL
import subprocess
import os
import psutil
from time import sleep
import signal
import multiprocessing
import numpy as np
import thread
class Sum: #again, this class is from ParallelPython's example code (I modified for an array and added comments)
def __init__(self):
self.value = np.zeros((1,512*512)) #this is the initialization of the sum
self.lock = thread.allocate_lock()
self.count = 0