Skip to content

Instantly share code, notes, and snippets.

View akerbos's full-sized avatar

Raphael akerbos

View GitHub Profile
@akerbos
akerbos / shortcuts.py
Last active April 26, 2018 08:18
Ubuntu keyboard shortcuts you want to disable for JetBrains IDEs
# cf. http://askubuntu.com/a/863486/69674
# Places to look for shortcuts in dconf-editor:
# - org.compiz.integrated
# - org.freedesktop.ibus.general.hotkey (?)
# - org.gnome.settings-daemon.plugins.media-keys
# - org.gnome.desktop.wm.keybindings
# - org.gnome.metacity.keybindings
shortcuts = {
# CTRL + ALT + Backspace
@akerbos
akerbos / dpquicksort.py
Created July 4, 2016 18:50
Dual-Pivot Quicksort
def swap(lst, i, j):
if min(i,j) >= 0 and max(i,j) < len(lst) and i != j:
lst[i], lst[j] = lst[j], lst[i]
lst.log()
# This is Dual-Pivot Quicksort by Yaroslavskiy et al.
# Implemented following Sebastian Wild as in
# https://www.uni-trier.de/fileadmin/fb4/prof/INF/TIN/Theorietag/TR.pdf
# page 39
# Plus a bugfix: need to swap pivot candidates, otherwise swapping-in pivots in the end
@akerbos
akerbos / dpquicksort.py
Created July 4, 2016 18:09
Dual-Pivot Quicksort
def swap(lst, i, j):
if min(i,j) >= 0 and max(i,j) < len(lst) and i != j:
lst[i], lst[j] = lst[j], lst[i]
lst.log()
# This is Dual-Pivot Quicksort by Yaroslavskiy et al.
# Implemented following Sebastian Wild as in
# https://www.uni-trier.de/fileadmin/fb4/prof/INF/TIN/Theorietag/TR.pdf
# page 39
def dpquicksort(lst, left=0, right=None):
@akerbos
akerbos / remove-hot-qs-SE.css
Last active September 20, 2023 12:49
Remove Hot Network Questions on SE
@namespace url(http://www.w3.org/1999/xhtml);
/* From https://gist.github.com/akerbos/152d7891d2b8b34edf3a */
@-moz-document domain('stackoverflow.com'),
domain('stackexchange.com'),
domain('superuser.com'),
domain('serverfault.com'),
domain('stackapps.com'),
domain('askubuntu.com'),
@akerbos
akerbos / optimal_five_sort.rb
Last active November 18, 2020 00:32
Comparison-optimal sorting algorithm for five elements, plus testing code. (via Knuth TAoCP Vol 3, 2nd ed, 5.3.1)
def swap(a, i, j)
t = a[i]
a[i] = a[j]
a[j] = t
end
def sort(a)
# Sort first two pairs
swap(a,0,1) if a[1] < a[0]
swap(a,2,3) if a[3] < a[2]
@akerbos
akerbos / parallel-listen.rb
Created May 6, 2015 06:39
MWE for conflict of listen and parallel gems
#!/usr/bin/ruby
require 'rubygems'
gem "parallel"
require 'parallel'
gem "listen"
require 'listen'
listener = Listen.to('.') do |modified, added, removed|
$changetime = Time.now
@akerbos
akerbos / Fix SE top bar to window top
Last active September 18, 2017 21:20
Changes the new Stack Exchange top bar so that it stays fixed even when scrolling.
@namespace url(http://www.w3.org/1999/xhtml);
@-moz-document domain('stackoverflow.com'),
domain('stackexchange.com'),
domain('superuser.com'),
domain('serverfault.com'),
domain('stackapps.com'),
domain('askubuntu.com'),
domain('mathoverflow.com'),
domain('answers.onstartups.com'),