Skip to content

Instantly share code, notes, and snippets.

View alxn's full-sized avatar
🧑‍💻

Alun Evans alxn

🧑‍💻
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;
@jbenet
jbenet / simple-git-branching-model.md
Last active April 9, 2024 03:31
a simple git branching model

a simple git branching model (written in 2013)

This is a very simple git workflow. It (and variants) is in use by many people. I settled on it after using it very effectively at Athena. GitHub does something similar; Zach Holman mentioned it in this talk.

Update: Woah, thanks for all the attention. Didn't expect this simple rant to get popular.

@dimhold
dimhold / gist:5759950
Created June 11, 2013 19:41
Unit tests just for understand: What is a true way of unit testing
package how.to.use.mockito;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import java.io.ByteArrayInputStream;
import java.io.FileOutputStream;
@vorburger
vorburger / gist:3429822
Created August 22, 2012 22:03
How to find an available (free) TCP port in Java
/**
* Returns a free port number on localhost.
*
* Heavily inspired from org.eclipse.jdt.launching.SocketUtil (to avoid a dependency to JDT just because of this).
* Slightly improved with close() missing in JDT. And throws exception instead of returning -1.
*
* @return a free port number on localhost
* @throws IllegalStateException if unable to find a free port
*/
private static int findFreePort() {
@jboner
jboner / latency.txt
Last active May 10, 2024 14:27
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers (~2012)
----------------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD
@dialtone
dialtone / pivotal_to_github.py
Created September 23, 2011 00:48
Migrate from Pivotal Tracker to GitHub issues
import re
import sys
import csv
import json
import urllib2
from datetime import datetime
from collections import defaultdict as dd
@bradfordcp
bradfordcp / pre-commit
Created February 10, 2011 15:17
Git pre-commit hook to generate documentation and add it to the commit, may be places within .git/hooks
#!/bin/sh
#
# Regenerates documentaion and adds it to the commite
#
# To enable this hook, rename this file to "pre-commit".
echo
echo "Regenerating Documentation"
echo
rake doc:generate
echo