Skip to content

Instantly share code, notes, and snippets.

View N02870941's full-sized avatar
🎯
Focusing

N02870941

🎯
Focusing
View GitHub Profile
@N02870941
N02870941 / back_forward.js
Created December 13, 2017 19:47 — forked from sstephenson/back_forward.js
How to detect whether a hash change came from the Back or Forward button
var detectBackOrForward = function(onBack, onForward) {
hashHistory = [window.location.hash];
historyLength = window.history.length;
return function() {
var hash = window.location.hash, length = window.history.length;
if (hashHistory.length && historyLength == length) {
if (hashHistory[hashHistory.length - 2] == hash) {
hashHistory = hashHistory.slice(0, -1);
onBack();
@N02870941
N02870941 / Timsort
Created May 1, 2018 05:35 — forked from nandajavarma/Timsort
Timsort implementation using Python
#!/usr/lib/python
# -*- coding: utf-8 -*-
#
# This is a re-implementation of Python's timsort in Python
# itself. This is purely for learning purposes. :)
# References: [
# https://en.wikipedia.org/wiki/Timsort,
# http://wiki.c2.com/?TimSort
# ]
#