Skip to content

Instantly share code, notes, and snippets.

View delamonpansie's full-sized avatar

Yury Vostrikov delamonpansie

View GitHub Profile
@delamonpansie
delamonpansie / inotify.patch
Last active August 11, 2020 20:35
Fix O(n^2) in emacs-27/inotify support. This speedups LSP on big repositories.
diff --git a/src/inotify.c b/src/inotify.c
index 549a82b401..50ba2fab9f 100644
--- a/src/inotify.c
+++ b/src/inotify.c
@@ -202,18 +202,25 @@ add_watch (int wd, Lisp_Object filename,
uint32_t imask, Lisp_Object callback)
{
Lisp_Object descriptor = INT_TO_INTEGER (wd);
- Lisp_Object tail = assoc_no_quit (descriptor, watch_list);
+ Lisp_Object tail;
@delamonpansie
delamonpansie / gist:5585239
Created May 15, 2013 16:22
Backing store hook.
enableBackingStore dpy win = do
unmapWindow dpy win
sync dpy False
allocaSetWindowAttributes $ \attributes -> do
set_backing_store attributes always
changeWindowAttributes dpy win cWBackingStore attributes
mapWindow dpy win
sync dpy False
enableBackingStoreHook =
@delamonpansie
delamonpansie / gist:5585228
Created May 15, 2013 16:21
Hide window by moving it offscreen.
Wed May 15 20:18:11 MSK 2013 Yuriy Vostrikov <mon@unformed.ru>
* Hide window by moving it offscreen.
diff -rN -u old-xmonad/XMonad/Main.hsc new-xmonad/XMonad/Main.hsc
--- old-xmonad/XMonad/Main.hsc 2013-05-15 20:19:44.856112375 +0400
+++ new-xmonad/XMonad/Main.hsc 2013-05-15 20:19:44.860112375 +0400
@@ -274,6 +274,7 @@
-- configure a window
handle e@(ConfigureRequestEvent {ev_window = w}) = withDisplay $ \dpy -> do
ws <- gets windowset
+ wm <- gets mapped
import Graphics.UI.Gtk
import Graphics.Rendering.Cairo
render = do
moveTo 0 0
sequence_ $ replicate 50000 (relLineTo 0.01 0.01)
stroke
main :: IO ()
main = do
static uint32_t
_mh(put_slot)(struct _mh(t) *h, mh_key_t key)
{
uint32_t inc, k, i, p = h->n_buckets;
k = mh_hash(key);
i = k % h->n_buckets;
inc = 1 + k % (h->n_buckets - 1);
for (;;) {
if (mh_exist(h, i)) {
if (mh_eq(h->p[i].key, key))
@delamonpansie
delamonpansie / gist:1173496
Created August 26, 2011 14:21
Am I crazy?
static uint32_t
_mh(put_slot_x)(struct _mh(t) *h, mh_key_t key)
{
uint32_t inc, k, i, p = h->n_buckets, j = 0;
k = mh_hash(key);
i = k % h->n_buckets;
inc = 1 + k % (h->n_buckets - 1);
for (;;) {
if (mh_exist(h, i)) {
if (mh_eq(h->p[i].key, key))
@delamonpansie
delamonpansie / gist:1167510
Created August 24, 2011 07:40
lcd driver
#include <avr/io.h>
#include <avr/pgmspace.h>
#include <util/delay.h>
#include "lcd.h"
#define BUSY_FLAG 0b10000000
void wait();
char read(void)
#include <util/delay.h>
#include <avr/pgmspace.h>
#include <avr/io.h>
#include <avr/interrupt.h>
#include <stdlib.h>
#include "lcd.h"
void
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <sysexits.h>
#include <sys/time.h>
int main(int argc, const char *argv[])
{
if (argc > 2) {
@delamonpansie
delamonpansie / gist:1011822
Created June 7, 2011 07:26
ioping with time
--- ioping.c.orig 2011-06-07 11:23:20.533184637 +0400
+++ ioping.c 2011-06-07 12:02:50.652665892 +0400
@@ -457,11 +457,12 @@
if (this_time > part_max)
part_max = this_time;
- if (!quiet)
- printf("%lld bytes from %s (%s %s): request=%d time=%.1f ms\n",
- (long long)ret_size, path, fstype, device,
+ if (!quiet) {